Saturday, June 14, 2008

Linux Commands - Part 3

find -This command is use t find files and folders

 find . -name amal -print         
 {find amal in current directory and print output}

 find /home -name a*  -print   
 {find things starts with a in /home directory and print output}

 find /home -name a* -type d  -print   
 {find directories starts with 'a' in /home directory and print output}

 find /home -name a* -type f  -print    
 {find filesstarts with a in /home directory and print output}

 find / -atime +7 -name *.conf -print
 {find every thing end with “.conf” and access before last 7 days in / (root)}

  find / -atime -7 -name *.conf -print
 {find every thing end with “.conf” and access with in last 7 days in / (root)}

  find / -atime 7 -name *.conf -print
  {find every thing end with “.conf” and accessed day 7 / (root)

  find . -name meli -type f -exec rm {} \;
 {find files named 'meli' in current directory and remove them}

  Hints: 
  [-atime,-amin,-ctime,-cmin, -name,-exec, -print, -type]

 locate - This also used to find files

  locate Saman               {find file named Saman}
  locate M*                    {find files start with M}
  locate -c Saman           {display only matching count}