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 06:52 AM
script - replace text in file frustrated1 Shell Programming and Scripting 4 01-01-2006 11: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 Search this Thread Display Modes
  #1  
Old 10-04-2001
Registered User
 

Join Date: Oct 2001
Location: Manchester
Posts: 2
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  
Old 10-04-2001
Perderabo's Avatar
Unix Daemon
 

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

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
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  
Old 10-04-2001
Registered User
 

Join Date: Oct 2001
Location: Manchester
Posts: 2
Cheers LivinFree

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:37 PM.


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

Content Relevant URLs by vBSEO 3.2.0