← linux commands
Views:
mv command
The mv command is used to rename or move files/directories.
Syntax: mv [options] source destination
Example:
mv folder1/config.txt folder2/

Options:
-i
To ask before overwriting
Example
mv -i styles/* src/styles/

Renaming a file
mv path/oldname path/newname
Example: Renaming all .js files in components directory to .jsx
for f in src/components/*.js; \
do mv $f "${f%.js}.jsx"; \
done;
In the end of first and second line, \ is used for multi-line command.
In the above example the value of $f variable will be:
- src/components/Button.js
- src/components/Input.js
And, ${f%.js} will basically remove the .js from the above $f variable. So, that we can remove .js and add .jsx, to know more about it check here.
