Linux cheat sheet

Posted by s1mple on Dec 30, 2008 in Linux, Tips & Triks |

- show disk usage: du
- show disk capacity: df
- search word from file inside directory:
find /start/dir -exec grep -q my_search_word {} \; -print
- search files with specific name inside directory (HP-Unix, maxdepth=1):
find . \( ! -name . -prune \) \( -name “*TEST1*.ps” -o -name “*TEST2*.ps” \) -mtime +30 -type f
find /parent/child \( ! -name child -prune \) \( -name “*TEST1*.ps” -o -name “*TEST2*.ps” \) -mtime +30 -type f

Tags:

2 Comments

  • mr.bho says:

    just use grep:
    $ grep -r -i [my_search_word] /start/dir/*

    -r will search recursively
    -i will ignores case-sensitives

    you can use awk to print file_name only.

    detail see man grep :)

    find will index all files under /start/dir and after that throws as grep input before print to standard output.

    cheers…
    -bho

  • s1mple says:

    thanks for the info mr.bho, it works.
    I am suck in awk and sed, will learn about it :(

Leave a Reply

XHTML: You can use these tags:' <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Copyright © 2010 Simple Difference All rights reserved.
Desk Mess Mirrored v1.4.3.1 theme from BuyNowShop.com.