Well, using the $ () 'operator on the head is the usual way to get the output of a bash command. Since it covers a subshell, it is not so effective.
I tried:
UUID=$(grep UUID /etc/fstab|awk '/ext4/ {print $1}'|awk '{print substr($0,6)}') echo $UUID
it works great :)
EDIT:
Of course, you can shorten your command:
# First step : Only one awk UUID=$(grep UUID /etc/fstab|awk '/ext4/ {print substr($1,6)}')
Again:
You can also use awk with the file argument:
# Third step : awk use fstab directlty UUID=$(awk '/UUID.*ext4/ {print substr($1,6)}' /etc/fstab)
neuro
source share