CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums

Find & Replacement & Delete

Register Blogs Members List Search Today's Posts Mark Forums Read

Rate this Entry

Find & Replacement & Delete

Posted January 19, 2012 at 12:13 by lakeat

Here are some tips, to show that linux is really very powerful, once you know how to use it.

Example-1
If you want to find or replacement, you dont need to open an editor, gedit, or vi. You can just simply do the following (choose one).
Why not just vi and :%s....? Because, the following command can be implemented in a shell scripts, so once you have dozens of files to operate, this is the better way.

perl -e "s/old_string/new_string/g"
sed -i 's/ugly/beautiful/g' /home/bruno/old-friends/sue.txt


Example-2
Ever met some an situation, you run the simulation and ends with a lot of time snapshots, like 0.1, 0.2, ..., 1.1, 1.2, 1.3, ..., 1.8, 1.9, 2.0, 2.1, etc.
But you want to delete those folders end with odd numbers, like 0.1, 0.3, ..., 1.1, 1.3, ..., 1.9?

Delete them one by one? You must be kidding... Here is a better way:
rm -rf case/[0123456789].[13579]

Super cool, right?

There are lots of other tricks and tips, that are very useful for a CFD user.

Okay, time to delete Windows.

Wait, wait, wait, I am just joking, I love windows too.
Posted in Uncategorized
Views 2473 Comments 1 Edit Tags Email Blog Entry
« Prev     Main     Next »
Total Comments 1

Comments

  1. Old Comment
    hello
    can any one help me in sliding mesh technique used in train moving in tunnel. reply me on my email sheikhnasir39@gmail.com
    thanks and regards
    permalink
    Posted February 6, 2012 at 00:24 by sheikh nasir sheikh nasir is offline
 

All times are GMT -4. The time now is 00:27.