Quick Search for Useful Linux Commands

On October 21, 2016, in Mac/Linux, by jild13
  1. Count the number of files in the current directory:
    ls -1 | wc -l
    ls -l | grep -v ^l | wc -l
    Reference: http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x700.html
  2. Remove all the files with name XXX* in the current directory:
    find . -name “XXX*” -print0 | xargs -0 -I {} rm {}
  3. List the total size of each folder (-s is to list only total size):
    du -sh directory
    du -h directory

 

 

 

TO BE UPDATED