The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to search and replace text in same file Vrgurav Shell Programming and Scripting 1 04-25-2008 03:20 AM
how to replace one line in text with several lines FunnyCats UNIX for Dummies Questions & Answers 1 01-18-2007 05:52 AM
script - replace text in file frustrated1 Shell Programming and Scripting 4 01-01-2006 10:10 PM
Search and replace multi-line text in files marz Shell Programming and Scripting 10 10-10-2005 05:05 AM
replace text in a file from the command line... dudboy UNIX for Dummies Questions & Answers 1 09-04-2001 11:31 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-04-2001
Registered User
 

Join Date: Oct 2001
Location: Manchester
Posts: 2
Stumble this Post!
Question Replace line of text in a file

I need to change the first line a file from

"HDR,{any_number}",,,,,

where {any_number} is incremental for each file

to

HDR,{any_number}

Can someone please suggest an easy way please

Regards

Col
__________________
Col Chase
Forum Sponsor
  #2 (permalink)  
Old 10-04-2001
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,425
Stumble this Post!
I don't understand exactly what you want to do. Could you post an example or two?
  #3 (permalink)  
Old 10-04-2001
LivinFree's Avatar
Goober Extraordinaire
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
Stumble this Post!
In the example I'm giving, I tested it with a text file name "file". You may need to rework this a little, but I think it might fit your needs:


cat file


"HDR,56",,,,,
"HDR,31",,,,,,
"HDR,66",,,,,
"HDR,59",,,,,

sed -e 's/\"//g' file | cut -d, -f1-2


HDR,56
HDR,31
HDR,66
HDR,59



If you need to, you can redirect the output to a different file.
  #4 (permalink)  
Old 10-04-2001
Registered User
 

Join Date: Oct 2001
Location: Manchester
Posts: 2
Stumble this Post!
Cheers LivinFree

Your advise was correct and it now works a treat
__________________
Col Chase
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:20 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0