tips.paddyonline.net

If you need tips & tricks, here they are...

Unix Tips & Tricks

This section is all about Unix Tips & Tricks.

Most unix flavors contain a lot of utilities that can be used in various ways. Here I will keep my own "things" I use daily or only once just to remember it for a later use.

Compare time on two files in (T)CSH

Compare time on two files in (T)CSH

I really don't like BASH or SH so I try to find ways not to use it.

This is what I came up to for use instead of [< file > -lt < file2 >] compare

if ( (-M < file1 >) >= (-M < file2 > ) )

Read more: Compare time on two files in (T)CSH

Find and Replace in many files

Find and Replace in many files

This is to describe how you can find and replace a text in many many files at once. It might take some time .. but it will do the job.

The FIND and SED way

find . -type f -exec sed -i 's/OLDSTRING/NEWSTRING/g' {} \;

Example

find . -type f -exec sed -i 's/\/usr\/local\/home/\/usr\/local\/new\/home/g' {} \;
find . -type f -exec sed -i 's/Beelzebub/God/g' {} \;

Observe that paths or text with a / in them need the / to be escaped(\) for sed to accept it as a / and not end of statement.

Please consider supporting our efforts.


We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.