pull/496/merge
Frank Deng 2018-01-10 05:06:12 +00:00 committed by GitHub
commit bcb06bbcda
1 changed files with 17 additions and 0 deletions

View File

@ -205,6 +205,15 @@ Notes:
5
```
- Iterate on command line arguments containing whitespace:
```sh
while [ -n "${1}" ]; do
FILENAME="${1}";
#Do some works on "${FILENAME}"
shift 1;
done;
```
## Processing files and data
@ -255,6 +264,7 @@ Notes:
repren --renames --from '(.*)\.bak' --to '\1' *.bak
# Same as above, using rename, if available:
rename 's/\.bak$//' *.bak
rename 's/(.*)\.bak/$1/' *.bak
```
- 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. When security restrictions allow, using `rsync` instead of `scp` allows recovery of a transfer without restarting from scratch. 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:
@ -386,6 +396,13 @@ A few examples of piecing together commands:
}
```
- Extract basename and extension from a given filename under bash shell without using any external commands:
```sh
FILENAME='README.1.md';
BASENAME="${FILENAME%.*}"; # Shows "README.1"
EXTENSION="${FILENAME##*.}"; # Shows "md"
```
## Obscure but useful