wc
wc -w
filename returns the number of words in that
file.
wc -l /etc/passwd returns the number of line in passwd file
wc -c /etc/passwd returns the number of character in the passwd file
wc -l /etc/passwd returns the number of line in passwd file
wc -c /etc/passwd returns the number of character in the passwd file
sed
#swap first windows to linux in every line and save to new file
sed 's/Windows/Linux/' opsys > newopsys
# swap every windows to linux in every line and save to new file
sed 's/Windows/Linux/g' opsys > newopsys
awk
#read out the username of every user with a Mike
in column 1 of /etc/passwd
awk '/Mike/ {print $1}' /etc/passwd
# apply all users with user1's quota
edquota -p user1 ` -F: '$3 > 499 {print $1}' /etc/passwd`
Then if you want to enable grace periods for all users, run
the edquota -t command.
# print user id and user name in /.etc/passwd with space
awk -F: ' {print $3,$1} ' /etc/passwd
# print field 1 2 3 without space
awk -F : '{ print $1 $2 $3 ]' /etc/passwd
# print user id and user name in /.etc/passwd with space
awk -F: ' {print $3,$1} ' /etc/passwd
# print field 1 2 3 without space
awk -F : '{ print $1 $2 $3 ]' /etc/passwd
转载于:https://blog.51cto.com/johnnyxing/197155