Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-07-2012
Registered User
 

Join Date: Apr 2011
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
replacing by sed

hi
my input file has got
>,,,, or >, or >,,,,,,
there are independent number of commas after >....
i want the o/p as > only that is just to remove "," after">"

another is:
i want to replace the last line of the file and to replace it by "hello"...how to do?...
any nice script
plz help
Sponsored Links
    #2  
Old 02-07-2012
Registered User
 

Join Date: Jun 2011
Posts: 65
Thanks: 6
Thanked 14 Times in 14 Posts
Data File Example:

Code:
$ cat data
Knight Eon >,,,,
Hello World >,,
Hello Earth >
How is everyone >,,,,,, Around >,, Yo >,

The relevant SED Script:

Code:
sed -e 's/>,*/>/g' data

Output:

Code:
$ sed -e 's/>,*/>/g' data
Knight Eon >
Hello World >
Hello Earth >
How is everyone > Around > Yo >

Combining your second query:


Code:
$ sed -e 's/>,*/>/g;$s/.*/Hello/g' data
Knight Eon >
Hello World >
Hello Earth >
Hello


Last edited by knight_eon; 02-07-2012 at 01:22 AM.. Reason: Updated for second query
Sponsored Links
    #3  
Old 02-07-2012
Registered User
 

Join Date: Apr 2011
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
hi all,

thanks alot ....it worked!!!!!
gr8 efforts.......highly appreciate all of your help and efforts
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
replacing ' with '' using sed DushyantG Shell Programming and Scripting 7 03-31-2011 04:52 AM
Replacing \n,\n with , skerit Shell Programming and Scripting 7 12-10-2008 10:56 AM
replacing using sed shailesh_arya Shell Programming and Scripting 2 07-11-2008 12:06 AM
replacing with `pwd` oldtrash Shell Programming and Scripting 6 04-09-2004 06:24 PM
replacing \n by \r\n crashnburn UNIX for Dummies Questions & Answers 3 11-24-2003 02:49 PM



All times are GMT -4. The time now is 04:31 AM.