From 86d1ce58a90e6d81b0d8ce456afbcd39a2f0a9c9 Mon Sep 17 00:00:00 2001 From: agxcul Date: Wed, 6 May 2015 15:14:49 +0800 Subject: [PATCH] add command [more] and some more example for command [awk] --- cheat/cheatsheets/awk | 6 ++++++ cheat/cheatsheets/more | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 cheat/cheatsheets/more diff --git a/cheat/cheatsheets/awk b/cheat/cheatsheets/awk index bf554bc..dbc670e 100644 --- a/cheat/cheatsheets/awk +++ b/cheat/cheatsheets/awk @@ -1,2 +1,8 @@ # sum integers from a file or stdin, one integer per line: printf '1\n2\n3\n' | awk '{ sum += $1} END {print sum}' + +# using specific character as separator to sum integers from a file or stdin +printf '1:2:3' | awk -F ":" '{print $1+$2+$3}' + +# print a multiplication table +seq 9 | sed 'H;g' | awk -v RS='' '{for(i=1;i<=NF;i++)printf("%dx%d=%d%s", i, NR, i*NR, i==NR?"\n":"\t")}' diff --git a/cheat/cheatsheets/more b/cheat/cheatsheets/more new file mode 100644 index 0000000..c1ee9d9 --- /dev/null +++ b/cheat/cheatsheets/more @@ -0,0 +1,3 @@ +# To show the file start at line number 5 +more +5 file +