Useful Linux Commands

Using mv to prefix files

The following command prefixes all files with the prefix 2013-10-22_. This is useful for small rename operations

for f in * ; do mv "$f" "2013-10-22_$f" ; done

# Files per Extension

Recursively lists all file extensions in the current folder and below, including a count how many files there are per extension.

find . -type f | sed 's/.*\.//' | sort | uniq -c

Clean Commandline History

history -c

Count the number of files and folders (non recursive)

ls -1 targetdir | wc -l

Count the number of files (recursively)

find . -type f | wc -l

Leave a comment

Your email address will not be published. Required fields are marked *