Search commands:
Find: search the file by name, type or attributes
- find ~/ -name “github.pem” # find by file name
- find . -type f # find all files in specific directory
- find . -type d # get all directory and sub directory specific location
- find . -mtime -7 # get modified files in last 7 days
grep – search inside a file
- grep “error” filename # find string
- grep -i “error” file name # case-insestive search
- grep -r “error” src/ search all files in dir and sub dir
- grep -n “error” logfile.txt # print line number where error find
locate – fast filename search
locate github.pem
link – one file point to another file point
ln
-
softlink : if delete original file application will break
-
hardlink : this will works still delete original file
-
ln -s source desc
-
ln source desc
compress the files using tar
-
tar -czvf spring.tar spring-petclinic/
- -c create file
- -z zip file
- -v vebsore
- -f force
-
tar -xzvf spring.tar
-
Extract to a specific folder: tar -xf filename.tar.gz -C /path/to/directory
