Awk: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 12: | Line 12: | ||
Duplicate entries in the passwd file? Compare these: | Duplicate entries in the passwd file? Compare these: | ||
<pre> | <pre> | ||
awk -F: '{print $1}' /etc/ | awk -F: '{print $1}' /etc/passwd | sort -u | wc -l > temp1 | ||
awk -F: '{print $1}' /etc/ | awk -F: '{print $1}' /etc/passwd | sort | wc -l > temp2 | ||
diff temp1 temp2 | diff temp1 temp2 | ||
</pre> | </pre> |
Revision as of 22:32, 27 June 2011
Pick out the fourth token:
mac=`/sbin/arp -a $ip | awk '{print $4}'`
Separate by = instead of whitespace:
echo "a=b=c" | awk -F= '{print $3}' # selects "c"
Duplicate entries in the passwd file? Compare these:
awk -F: '{print $1}' /etc/passwd | sort -u | wc -l > temp1 awk -F: '{print $1}' /etc/passwd | sort | wc -l > temp2 diff temp1 temp2