Skip to content

Instantly share code, notes, and snippets.

@dpaluy
Last active December 13, 2019 22:14
Show Gist options
  • Select an option

  • Save dpaluy/8930c8c74b52f0947e81070dbe73df1c to your computer and use it in GitHub Desktop.

Select an option

Save dpaluy/8930c8c74b52f0947e81070dbe73df1c to your computer and use it in GitHub Desktop.
Shell useful tools
# Total number of files in Folder
ls -l FOLDER | egrep -c '^-'
# Rename all files in Folder
for f in *; do [[ -f "$f" ]] && mv "$f" "UNIX_$f"; done
# or
ls | xargs -I {} mv {} Unix_{}
# output files from /dist to filenames.txt
find /dist -type f -maxdepth 1 > filenames.txt
# Copy a big amount of files from source to destination
find source/ -type f -maxdepth 1 -exec sh -c 'mv "$@" "$0"' destination/ {} +
# list files and directories
ls -d "$PWD"/* > result.txt
# sort directories by size
sudo du -sh * | sort -hr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment