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'
.awk '$0 ! ~ /^#|swap|UUID/ {print $1, $2, $3}' /etc/fstab
.awk
write to stdout (:grep
ping intoawk
is a kissing cousin to the Useless Use of Cat.