Your syntax is rather weird. Probably refactor along the lines of
awk 'NR == FNR {
if ($1 ~ /^\//) arr[$6]=$1 " " $2 " " $3 " " $4 " " $5
next }
/fd0|ram|loop|sr0|hdc|cdrom|\[SWAP\]/ { next }
{ print $1 " " $3 " " $4 " " arr[$4] }' \
<(df -P --exclude={tmpfs,devtmpfs,squashfs,overlay}) \
<(lsblk -n -b --output KNAME,NAME,SIZE,MOUNTPOINT)
Filesystem
doesn’t match ^/
so I took that out. The regex [SWAP]
was incorrect; I assume you meant to match that literally. Awk can do everything egrep
and sed
can do, so I refactored those out.
The beef here is the next
inside the first condition, to avoid printing those lines. The refactoring to read two separate file handles also makes the script somewhat more idiomatic and, hopefully, understandable.
CLICK HERE to find out more related problems solutions.