cp, mv, rm
In this page:
cp, mv, rm
cp copies files, mv moves or renames them, and rm deletes them. cp -r and rm -r operate recursively on directories. These are the fundamental filesystem manipulation commands used constantly in shell scripts.
Warning: rm -rf deletes recursively without confirmation — a typo in the path can destroy far more than intended.
Example: cp, mv, rm
#!/bin/bash
echo "original" > original.txt
cp original.txt copy.txt
mv copy.txt renamed.txt
ls original.txt renamed.txt
rm renamed.txt
echo "renamed.txt removed"
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 13 topics to unlock
0/13 topics done
Complete these topics first: