DEV Community

Aravinthan
Aravinthan

Posted on

Linux - Searching Commands

Linux - Searching Commands

This is Part 11 of the Linux CLI Commands series.

πŸ‘‰ Previous: Linux - Job Schedule Commands
πŸ‘‰ First Part: Linux - System Commands

Searching Commands

ls -lrt -a -- show the hidden files
ls -lart -- show the hidden files
ls -lrt d* -- starting files from d
echo -- print statment
test -d file_name && echo "dir" || echo "not-dir" -- to check dir or not-dir
which file or dir -- show the path
locate filename -- show the full path (if locate is not work install updatedb)
whereis filename -- command path
what is command -- it show the defination of the command
find -name filename -- to find file or dir
find -iname filename -- find files in upper case or in lower case
find -mmin -10 filename -- to find 10 min before files and dir
find -mtime -10 filename -- to find 10 days before files and dir
find -type f or d -- to find files or dir
find -perm 644 -- to find file and dir in permission 644
. -- current directory
~ -- home directory
find -size 690c -- to find file in size 690
find -empty -- to find empty files

Note:
-exec rm -rf {} \; -- to remove file or dir

find -user user_name -- find file or dir in a paticular user
grep findingword filename -- to find a word
grep -o findingword filename -- only that word (in lower case)
grep -io findingword filename -- only that word (upper and lower case)
grep -v findingword filename -- except that finding word (lower case)
grep -iv findingword filename -- except that finding word (upper and lower)
grep -c findingword filename -- count that word (in lower case)
grep -ic findingword filename -- count that word (in upper and lower case)
egrep "word1|word2" filename -- to find two word (in lower)
egrep -i "word1|word2" filename -- to find two word (in lower and upper)
fgrep "," filename -- find with special character
awk '{print $1}' finename -- print first field
tr 's' '$' <inputfile> outputfile --translate s to $ in outputfile
tr -d 's' <inputfile> outputfile -- delete s and store in outputfile
tr 'ad' 'ba' <inputfile> outputfile -- translate a to b and b to a
cut -b 1,2 filename -- cut first and second bytes in a file
cut -c 1,2 filename -- cut first and second chara in a file
cut -d ':' -f1 -- cut first column separated by ':'
cut -d ':' -f1,2 -- cut first and second field separated by ':'
sed -- stream editor
sed 's/find/replace/g' filename -- find and replace word that pressent
sed '3d' filename -- delete third line in a file
sed -n '2p' filename -- print the second line in a file

Top comments (0)