mirror of
https://github.com/xmengnet/the-art-of-command-line.git
synced 2024-12-24 10:26:27 +08:00
More info on rsync
And a useful tip for deleting files quickly.
This commit is contained in:
parent
16ab074409
commit
7b85fba0bd
1 changed files with 5 additions and 0 deletions
|
@ -217,6 +217,11 @@ Notes:
|
|||
repren --full --preserve-case --from foo --to bar .
|
||||
```
|
||||
|
||||
- As the man page says, `rsync` really is a fast and extraordinarily versatile file copying tool. It's known for synchronizing between machines but is equally useful locally. It also is among the [fastest ways](https://web.archive.org/web/20130929001850/http://linuxnote.net/jianingy/en/linux/a-fast-way-to-remove-huge-number-of-files.html) to delete large numbers of files:
|
||||
```sh
|
||||
mkdir empty && rsync -r --delete empty/ some-dir && rmdir some-dir
|
||||
```
|
||||
|
||||
- Use `shuf` to shuffle or select random lines from a file.
|
||||
|
||||
- Know `sort`'s options. For numbers, use `-n`, or `-h` for handling human-readable numbers (e.g. from `du -h`). 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`.
|
||||
|
|
Loading…
Reference in a new issue