Posts

Showing posts from November, 2020

Some useful Unix commands

The most basic: navigation:  cd, cd .. ls ls -alShr ls -alShr | less ls -alhF cp, mv, rm, rm -r  The locations in which the shell searches for executables: echo $PATH Other useful echo commands: echo $SHELL Finding stuff: find command Find all files with name "*alpha*" : find . -name "*alpha*" -print List of all such files in a text file find . -name "*alpha*" -print >> list.txt Number of such files: find . -name "*alpha*" -print | wc -l Find all txt files created in the last 60 days:  find /home/you -iname "*.txt" -mtime -60 -print awk command sed command grep command locate command List only directories... find . -type d -depth 1 ls -F | grep / ls -ld -- */ Shell script: create many (in this example, 100) directories: for i in {1..100}; do mkdir subdirectory_$i; done mkdir subdirectory_{1..100} Add pdf extension to all files in a folder: for i in *; do mv $i ${i}.pdf ; done Finding the locatio...