Learn N Try

For all Lean Enthusiast

Standard Input, output and error

  • Standard input (stdin) <
  • Standard output (stdout) >
  • Standard error (stderr) 2>
  • Append >>

 

Ex.      # date > /tmp/timestamp

#tail – n 100 /var/log/dmesg > /tmp/bootmsg

 

Grep

This utility is used for searching plain text.

# grep -in root /etc/passwd                         //ignore case and show line number

# grep -E “root|student” -o -i -n /etc/passwd       //only show name with exact line number

# grep ^root /etc/passwd                 //1st line in file where written “root”

 

Find

Use to search and locate list of file/directory based on search condition.

# find / -size 100M

#find / -size 10M 2> /dev/null

# find /etc -name passwd > /tmp/output 2> /dev/null

# find / -type f -user root 2> /dev/null                    // will search file own by “root”

# find / -type d -user root 2> /dev/null                   // will search directory own by “root”

# find / -perm 775 2> /dev/null > /opt/test

#find / -perm /g+s                                                     //Find all file on which SGID is set

# find / -type f -name “abc.txt” -exec rm -f {}\;

# find / -mtime 50                 // will find files modified 50 days back

# find / -atime 50