Linux / Unix stuff

City Melbourne Australia

Just some occasional unix / linux CLI related notes

To add a .txt to the end of a number of files in a directory

for file in report_*; do mv “$file” “${file}.txt”; done

for f in * ; do mv “$f” “$f.txt” ; done

To delete every file in a directory that does not end in .txt

sudo find . -type f ! -name ‘*.txt’ -delete