|
[Sponsors] |
September 28, 2004, 07:32 |
Question
|
#1 |
Guest
Posts: n/a
|
I know this is not directly related to CFD, but I am sure many of you can help. I have a large CFD code, it contains about 15,000. lines, but everyother line in this code is blank, so the total number of lines is 30,000., at the moment. How can I delete all these blank lines, which editor and what command? Thank you.
|
|
September 28, 2004, 08:01 |
Re: Question
|
#2 |
Guest
Posts: n/a
|
I forgot ot say that this is a FORTRAN code, so I can use any editor, and in either OS of WIndows or Linux.
|
|
September 28, 2004, 10:40 |
Re: Question
|
#3 |
Guest
Posts: n/a
|
perl -p -i.bak -e 's/^\s*$//g' file.f
|
|
September 28, 2004, 10:46 |
Re: Question
|
#4 |
Guest
Posts: n/a
|
Thanks, but in which editor I should use this command?
|
|
September 28, 2004, 10:57 |
Re: Question
|
#5 |
Guest
Posts: n/a
|
Open a text console on a unix maschine and type this command there.
|
|
September 29, 2004, 09:40 |
Re: Question
|
#6 |
Guest
Posts: n/a
|
The following search and replace command works in the vi editor.
:g/^$/d |
|
October 2, 2004, 11:05 |
Re: Question
|
#7 |
Guest
Posts: n/a
|
Wow. What a powerful scripting language. How does that code work? I tried it out and it worked great. I might learn it!
|
|
October 3, 2004, 18:24 |
Re: Question
|
#8 |
Guest
Posts: n/a
|
-p makes perl loop over all lines
-i makes perl first rename your file and then output to the original file name -e makes perl execute the command following it 's/^\s*$//g' is a regular expression command which replaces all lines that only contain white-space characters with nothing (ie deletes them) To learn more about perl get the definitive perl book, the camel (see http://www.oreilly.com/catalog/pperl3/) or visit www.perl.com |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
question about uds | tanven | FLUENT | 2 | July 5, 2015 12:22 |
Unanswered question | niklas | OpenFOAM | 2 | July 31, 2013 17:03 |
internal field question - PitzDaily Case | atareen64 | OpenFOAM Running, Solving & CFD | 2 | January 26, 2011 16:26 |
CHANNEL FLOW: a question and a request | Carlos | Main CFD Forum | 4 | August 23, 2002 06:55 |
question | K.L.Huang | Siemens | 1 | March 29, 2000 05:57 |