мелкие доработки 4, и убран дубль одного совета (xargs)

This commit is contained in:
spmbt
2015-07-09 20:44:13 +03:00
parent 0dba6d474a
commit 7508bda543
2 changed files with 28 additions and 40 deletions

View File

@ -287,12 +287,6 @@ A few examples of piecing together commands:
find . -type f -ls
```
- Use `xargs` or `parallel` whenever you can. Note you can control how many items execute per line (`-L`) as well as parallelism (`-P`). If you're not sure if it'll do the right thing, use xargs echo first. Also, `-I{}` is handy. Examples:
```sh
find . -name '*.py' | xargs grep some_function
cat hosts | xargs -I{} ssh root@{} hostname
```
- Say you have a text file, like a web server log, and a certain value that appears on some lines, such as an `acct_id` parameter that is present in the URL. If you want a tally of how many requests for each `acct_id`:
```sh
cat access.log | egrep -o 'acct_id=[0-9]+' | cut -d= -f2 | sort | uniq -c | sort -rn