Translate

Saturday, 26 January 2013

Commands for Linux Part 5

Basic command for Linux Part 5

12) To Search a word and file from single or multiple files's


For word use grep command

Option 1:

   #command word (to be search) files (from you are searching)

example :
# grep gdm /etc/passwd /etc/group /etc/shadow
/etc/passwd:gdm:x:42:42::/var/lib/gdm:/sbin/nologin
/etc/group:gdm:x:42:
/etc/shadow:gdm:!!:15727::::::

 Option 2 :

#cat (for read or open the file) file (from you are searching) | (pipe) word (to be search)

example :

# cat /etc/passwd |grep gdm
gdm:x:42:42::/var/lib/gdm:/sbin/nologin


For file use find command

find - search for files in a directory

#command (find) file (from you are searching) Synopsis (here using name means by name we are searching) file (to be search)

example:

#find /etc/ -name passwd
/etc/pam.d/passwd
/etc/passwd


continue..
 

No comments:

Post a Comment