Searching Commands

  1. locate
  2. find
  3. awk
  4. grep

Locate Command:

locate file_name     //find files by name

Find Commands:

find -name file_name     //find the file_name
find . -name file_name
find -iname file_Name     //find the file with ignoring case
find -size 10M     //find the 10mb size files
find -empty     //find the empty files
find -size 0c     //find the empty files
find -amin -5     //last accessed 5 min
find -atime -1     //last accessed 1 day
find -cmin -5     //File’s status was last changed 5 minutes ago.
find -ctime -1     //File’s status was last changed 1 day ago.
find -mmin -3     //last modified 3min
find -mtime -1     //last modified 1day

AWK Commands: (column wised searching command)

awk {'print $1'} file_name     //show 1st column
ls -l|awk {'print $9'} file_name     //show 9th column

Grep Command: (print lines marching a pattern)

grep muthu file_name     //select matching lines
grep -v 'muthu' file_name     //select non-matching lines
grep -i 'muthu' file_name     //ignore-case
grep -c 'muthu' file_name     //count lines
grep --color 'muthu' file_name
cat file_name|grep -c muthu

Other Searching and Replace commands:

sed 's/muthu/pearl/' file     //show the replaced text
sed 's/muthu/pearl/' file > file2     //copy to replaced text
cat file|tr 's' '$'
ls -lrt|cut -d ':' -f2
which file_name
whereis file_name

Comments