shell: added renaming recursively

master
tiyn 1 year ago
parent 4c69c54ff6
commit ef1bed9d11

@ -24,6 +24,30 @@ The following is a list of Unix shells that are POSIX compliant.
This section addresses various different functions by and actions that can be
taken with shell commands.
### Renaming Files
Files can be renamed by using the `mv` command like in the following example.
```sh
mv old_name.ext new_name.ext
```
Another way to rename files that is especially useful if renaming a lot of files is needed is done
by using the command-line utility `rename`.
In the following example the string `string1` will be substituted by `string2` for a given file
`file.ext`.
```sh
rename 's/string1/string2/g' file.ext
```
Additionally `find` can be used to recursively substitute substrings in all files inside a folder
`folder` (including subfolders).
```sh
find folder -type f -exec rename 's/string1/string2/g' {} +
```
### Expansion
This section is based on the
@ -136,4 +160,3 @@ Error outputs (stderr) can be silenced by appending `2> /dev/null`.
The complete output of both stderr and stdout can be silenced by appending
`> /dev/null 2>&1` to the command.
A shortened version of it not possible on all shells is `&> /dev/null`.

Loading…
Cancel
Save