Skip to content

Instantly share code, notes, and snippets.

@emasaka
Created July 27, 2012 11:23
Show Gist options
  • Save emasaka/3187472 to your computer and use it in GitHub Desktop.
Save emasaka/3187472 to your computer and use it in GitHub Desktop.
# answer of http://d.hatena.ne.jp/Yamashiro0217/20120727/1343371036
## q1
cat log.txt
## q2
cut -d , -f 1,4 log.txt
## q3
grep ^server4 log.txt
## q4
wc -l < log.txt
## q5
sort -t , -k 3,3 -n log.txt | sort -t , -k 1,1 -s | head -n 5
## q6
sort -u log.txt | wc -l
## q7
cut -d , -f 3 log.txt | sort -u | wc -l
## q8 : doesn't match to question's output
cut -d , -f 1,4 log.txt | sort | uniq -c | sort -nr | head -n 1
## q9 : doesn't match to question's output
sed -e 's/server/xxx/;s/,.*//' log.txt | sort | uniq -c
## q10
cut -d , -f 3 log.txt | grep .. | sort -nu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment