5

awk command to change 1 field based on values of 2

view full story
linux-howto

http://forums.fedoraforum.org – This awk code outputs all fstab lines, prepending "nodev" to $4 (options) if $2 (mount point) matches "^/tmp$". But I want to add "nodev" only if it is not already in $4. How do I do that? I can't figure out how to add the second test. Code: awk -v FSYS="^/tmp$" -v FSOPT="nodev" -v FSOPTCOMMA="nodev," ' $2~FSYS{$4=FSOPTCOMMA$4}1' OFS="\t"  < /etc/fstab (HowTos)