I have the following code:
#!/bin/bash
FSTAB=` grep -vE "^#|swap|UUID" /etc/fstab | awk '{print $1,$2,$3}'`
for i in $FSTAB
do
echo "$i"
done
return this:
/dev/mapper/centos-root
/
xfs
/dev/sdb2
/hdos
xfs
The problem is that later I want to compare it, so I am returning it with line breaks and I want it to be returned in a single line without jumps, that is to say:
/dev/mapper/centos-root / xfs
/dev/sdb2 /hdos xfs
for [...]; done | tr -d '\n'
. – DopeGhoti Jan 30 '19 at 21:23FSTAB
could be reduced to:grep -vE "^#|swap|UUID" /etc/fstab | awk '{print $1,$2,$3}'
– jesse_b Jan 30 '19 at 21:32awk '$0 ! ~ /^#|swap|UUID/ {print $1, $2, $3}' /etc/fstab
. – DopeGhoti Jan 30 '19 at 21:33FSTAB
– jesse_b Jan 30 '19 at 21:33awk
write to stdout (: – DopeGhoti Jan 30 '19 at 21:34grep
ping intoawk
is a kissing cousin to the Useless Use of Cat. – DopeGhoti Jan 30 '19 at 21:42diff < <(awk '$0 ! ~ /^#|swap|UUID/ {print $1,$2,$3}' /etc/fstab) < <(mount | awk '$0 ! ~ /^ /{print $1,$3,$5}')
– jesse_b Jan 30 '19 at 22:07