Skip to main content

File Operation Commands

All file commands use Python's os, shutil, and pathlib under the hood, making them fully cross-platform. Glob patterns (*, ?, [...]) are expanded before the command runs.

cat — Print file contents

cat <file> [file ...]

Prints one or more files to stdout. Without arguments, reads from stdin.

cat README.md
cat file1.txt file2.txt
cat *.log | grep ERROR

touch — Create or update file

touch <file> [file ...]

Creates the file if it doesn't exist, or updates its modification time.

touch newfile.py
touch a.txt b.txt c.txt

mkdir — Create directory

mkdir [-p] <dir> [dir ...]
FlagDescription
-pCreate parent directories as needed; don't error if exists
mkdir src
mkdir -p a/b/c/d

rm — Remove files and directories

rm [-r] [-f] <path> [path ...]
FlagDescription
-r / -RRecursively remove directories
-fForce — suppress "not found" errors
-rfBoth flags combined
rm old_file.txt
rm -r build/
rm -rf dist/ __pycache__/
rm *.pyc
warning

rm -rf is irreversible. XShell does not move files to trash.


cp — Copy

cp [-r] <src> [src ...] <dst>
FlagDescription
-r / -RRecursively copy directories
cp config.json config.backup.json
cp -r src/ src_backup/
cp *.py scripts/

mv — Move / rename

mv <src> [src ...] <dst>
mv old_name.py new_name.py # rename
mv build/ dist/ archive/ # move into archive/
mv *.txt docs/ # move all text files

Glob expansion

All file commands support glob patterns expanded by XShell before the command runs:

rm *.pyc # all .pyc files
cp src/*.py dst/ # all Python files
ls **/*.json # all JSON files recursively (Python glob)