Saturday, March 3, 2012

Solaris commands

1. awk

Need to print the ufs filesystem listed in /etc/vfstab file

awk '($4 == "ufs") | printf("%s %s\n", $1, $3) }' /etc/vfstab

The above command will print filesystems which are commented as well. To print only the active filesystem, use the following commands

awk '(!/^#/ && $4 == "ufs") { printf("%s %s\n", $1, $3) }' /etc/vfstab

!/^#/ - ignore all the commented lines $4 - is the fourth column in the /etc/vfstab file


ls -ltr | awk 'BEGIN {print "File \t Owner"} {print $3 "\t" $9} END {print "-----Done-----" }'

No comments: