Showing posts with label Quick tips. Show all posts
Showing posts with label Quick tips. Show all posts

Thursday, June 19, 2008

SED & TR uses

Here are the quickies for my very own sed and tr:

To replace "NEWLINE" (\n) with "comma" (,)
cat filename | tr '\n' ','


To find "tree" and replace with "plant" in a file (using sed):
sed -i 's/tree/plant/g' filename

Thursday, January 3, 2008

Find command

Basic uses of find

How to find a file?
$ find /export/home -name testfile

How to find a file and its details?
$ find /export/home -name testfile -exec ls -l {} \;

How to find a file which is not modified since past 60 days?
$ find /export/home -mtime +60 -exec ls -l {} \;

How to find a file which is not accessed since past 60 days?
$ find /export/home -atime +60 -exec ls -l {} \;


How to find a directory
$ find /var/adm -type d


Advance uses of Find command

How to find a file which contains "report" word in it?
$ find /export/home -type f -exec grep "report" '{}' /dev/null \;