Linux commands - Frequently Used


To view all the process:

ps -ef | grep <pid>

Unzip: 

unzip filename.zip  

unzip file.zip -d destination_folder

 grep commands:

find . -name "*.*" | xargs grep "Search Text" -sl

 

To print file name, highlight matching text: 


find . -type f -name "*.*" -print0 | xargs --null grep --with-filename --line-number --no-messages --color --ignore-case "Search text"


To search in jar/zip file:  

find . -name "*.jar" -exec zipgrep "Search Text" '{}' \;

find . -name "*.jar" | xargs -I{} sh -c 'echo searching in "{}"; zipgrep "Search Text" {}' 

        find . -iname '*.jar' -printf "unzip -c %p | grep -q 'Search Text' && echo %p\n" | sh


docker cmd to find containers: 

docker ps | grep "container name"

 

 tail commands:

tail -F *.log | grep -E 'text-1'

To grep multiple strings:

tail -F *.log | grep "text-1|text-2|text-3'

 To redirect the tail results to new file

tail -F *.log | grep -E 'text-1'  > test.log

Comments

Popular posts from this blog

Java Design Patterns

Java 8 Concepts with Examples