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

Question

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

Reply
 
LinkBack Thread Tools Display Modes
Old   September 28, 2004, 06:32
Default Question
  #1
Jack
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.
  Reply With Quote

Old   September 28, 2004, 07:01
Default Re: Question
  #2
Jack
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.
  Reply With Quote

Old   September 28, 2004, 09:40
Default Re: Question
  #3
Jörn Beilke
Guest
 
Posts: n/a
perl -p -i.bak -e 's/^\s*$//g' file.f
  Reply With Quote

Old   September 28, 2004, 09:46
Default Re: Question
  #4
Jack
Guest
 
Posts: n/a
Thanks, but in which editor I should use this command?
  Reply With Quote

Old   September 28, 2004, 09:57
Default Re: Question
  #5
Jörn Beilke
Guest
 
Posts: n/a
Open a text console on a unix maschine and type this command there.

  Reply With Quote

Old   September 29, 2004, 08:40
Default Re: Question
  #6
Joe
Guest
 
Posts: n/a
The following search and replace command works in the vi editor.
:g/^$/d
  Reply With Quote

Old   October 2, 2004, 10:05
Default Re: Question
  #7
Interesting.
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!
  Reply With Quote

Old   October 3, 2004, 17:24
Default Re: Question
  #8
Jonas Larsson
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
  Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
question about uds tanven FLUENT 2 July 5, 2015 11:22
Unanswered question niklas OpenFOAM 2 July 31, 2013 16: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 05:55
question K.L.Huang CD-adapco 1 March 29, 2000 04:57


All times are GMT -4. The time now is 19:11.