mirror of
https://github.com/onceupon/Bash-Oneliner.git
synced 2024-11-22 12:57:01 +00:00
add awk
This commit is contained in:
parent
257008525c
commit
b21244ca49
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
|
// \w word character [0-9a-zA-Z_] \W not word character
|
||||||
|
|
||||||
|
|
||||||
|
#####a lot examples here
|
||||||
|
http://www.cyberciti.biz/faq/grep-regular-expressions/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##Sed
|
##Sed
|
||||||
[[back to top](#handy-bash-oneliner-commands-for-tsv-file-editing)]
|
[[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
|
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
|
```bash
|
||||||
awk '{s+=$1} END {print s}' filename
|
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)
|
#####print field start with string (e.g Linux)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
Loading…
Reference in New Issue
Block a user