mirror of
https://github.com/onceupon/Bash-Oneliner
synced 2024-11-26 14:40:16 +00:00
add awk
This commit is contained in:
parent
257008525c
commit
b21244ca49
1 changed files with 11 additions and 1 deletions
12
README.md
12
README.md
|
@ -132,6 +132,11 @@ grep -o -w "\w\{10\}\-R\w\{1\}"
|
|||
// \w word character [0-9a-zA-Z_] \W not word character
|
||||
|
||||
|
||||
#####a lot examples here
|
||||
http://www.cyberciti.biz/faq/grep-regular-expressions/
|
||||
|
||||
|
||||
|
||||
##Sed
|
||||
[[back to top](#handy-bash-oneliner-commands-for-tsv-file-editing)]
|
||||
|
||||
|
@ -458,12 +463,17 @@ detail here: http://stackoverflow.com/questions/33408762/bash-turning-single-c
|
|||
awk '{split($2,a,",");for(i in a)print $1"\t"a[i]}' file
|
||||
```
|
||||
|
||||
#####sum up a file
|
||||
#####sum up a file (each line in file contains only one number)
|
||||
|
||||
```bash
|
||||
awk '{s+=$1} END {print s}' filename
|
||||
```
|
||||
|
||||
#####average a file (each line in file contains only one number)
|
||||
```bash
|
||||
awk '{s+=$1}END{print s/NR}'
|
||||
```
|
||||
|
||||
#####print field start with string (e.g Linux)
|
||||
|
||||
```bash
|
||||
|
|
Loading…
Reference in a new issue