The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > SUN Solaris
.
google unix.com



SUN Solaris The Solaris Operating System, usually known simply as Solaris, is a free Unix-based operating system introduced by Sun Microsystems .

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
help with finding & replacing pattern in a file dusoo Shell Programming and Scripting 0 05-23-2008 03:59 AM
string with blank spaces psalas UNIX for Dummies Questions & Answers 4 04-16-2008 04:50 AM
Removing blank spaces from a file? dfs Shell Programming and Scripting 4 05-22-2007 05:59 PM
blank spaces getting deleted gander_ss Shell Programming and Scripting 5 05-15-2007 05:37 AM
To remove Continous blank spaces from a file in UNIX arunkumar_mca UNIX for Dummies Questions & Answers 1 12-08-2006 01:10 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-20-2005
Gerry405 Gerry405 is offline
Registered User
  
 

Join Date: Jun 2005
Location: Alexandria, Scotland
Posts: 46
finding & replacing blank rows/spaces in a file

Can anyone help me find and replace blank rows in a file with a numeric value (ie blankrow=someTxtOrNumValue), the file is over 500,000 rows long so it would need to be the quickest way as I'll need to do this for multiple files...I would be greatfull for any suggestions....thanks

sample file:
..............
J Smith
A Allan
B

fred
Tommy D
John Hall
.............
  #2 (permalink)  
Old 07-20-2005
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
Try...
Code:
awk '{print NF ? $0 : blankrow}' blankrow="someTxtOrNumValue" file1 > file2
  #3 (permalink)  
Old 07-21-2005
Gerry405 Gerry405 is offline
Registered User
  
 

Join Date: Jun 2005
Location: Alexandria, Scotland
Posts: 46
thanks

Thanks that works a treat, now I need to replace all the rows that have the number 0 with a text value like....(0=ASC) and I'll be done, I have read through the my man pages on awk and I can't understand them too well, what does the "NF ?" part do, I assume thats where it's search for empty rows so I tried changing it to "Nf 0" but that gave me errors as you would expect...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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




All times are GMT -4. The time now is 08:55 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0