mirror of
https://github.com/xmengnet/the-art-of-command-line.git
synced 2024-12-24 10:46:29 +08:00
parent
d5f6238975
commit
0f9b8a74b7
1 changed files with 1 additions and 3 deletions
|
@ -194,9 +194,7 @@ Notes:
|
|||
|
||||
- Use `shuf` to shuffle or select random lines from a file.
|
||||
|
||||
- Know `sort`'s options. Know how keys work (`-t` and `-k`). In particular, watch out that you need to write `-k1,1` to sort by only the first field; `-k1` means sort according to the whole line.
|
||||
|
||||
- Stable sort (`sort -s`) can be useful. For example, to sort first by field 2, then secondarily by field 1, you can use `sort -k1,1 | sort -s -k2,2`
|
||||
- Know `sort`'s options. Know how keys work (`-t` and `-k`). In particular, watch out that you need to write `-k1,1` to sort by only the first field; `-k1` means sort according to the whole line. Stable sort (`sort -s`) can be useful. For example, to sort first by field 2, then secondarily by field 1, you can use `sort -k1,1 | sort -s -k2,2`. For handling human-readable numbers (e.g. from `du -h`) use `sort -h`.
|
||||
|
||||
- If you ever need to write a tab literal in a command line in Bash (e.g. for the -t argument to sort), press **ctrl-v** **[Tab]** or write `$'\t'` (the latter is better as you can copy/paste it).
|
||||
|
||||
|
|
Loading…
Reference in a new issue