So we've examined covered a lot number of "framework" issue topics – argument handling, stream handling, error handling – in a systematic way. This section presents various tips and tricks for actually manipulating data, which can be useful both in writing scripts and in command line manipulations.
...
Expand |
---|
|
Add a count to the unique run lines then sort on it numerically, in reverse order. The 1st line will then be the job with the most lines (jobs). Code Block |
---|
| cat joblist.txt | cut -f 2 | sort | uniq -c | sort -k1,1nr | head -1
# 23 SA13038 |
|
field delimiter issues
sort – default delimiter is whitespace; change with -t or --field-separator option
utility | default delimiter | how to change | example |
---|
cut | tab | -d or --delimiter option | cut -d ':' -f 1 /etc/passwd |
sort | whitespace | -t or --field-separator option | sort -t ':' -k1,1 /etc/passwd |
|
|
|
|