The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem with output of find command being input to basename command... new_learner UNIX for Dummies Questions & Answers 2 12-14-2008 02:56 AM
awk/sed Command : Parse parameter file / send the lines to the ksh export command rajan_san Shell Programming and Scripting 4 11-06-2008 01:29 PM
assign a command line argument and a unix command to awk variables sweta_doshi Shell Programming and Scripting 0 08-08-2008 07:54 AM
Help Required: Command to find IP address and command executed of a user loggedout Security 2 08-06-2008 09:12 PM
inconsistent ls command display at the command prompt & running as a cron job rajranibl SuSE 5 07-30-2007 09:26 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 04-22-2009
oomanamemni oomanamemni is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 1
help with sed command

I'm new to shell programming and am trying to delete/replace certain characters in a pattern. Here's an example of what I'm trying to do.

input file has multiple lines of the following form

#0,v,g,n,n,n,(stuff....)
#1,x,g,n,c,n,(stuff..blah..blah)
#2,x,g,x,x,m,(stuff..blah)
...
#25,x,g,x,x,n,(stuff...)

and I want to output to be

#0,v,g,n,n,(stuff...)
#1,u,g,n,c,(stuff....)
#2,u,g,n,n,(stuff...)
.....
#25,u,g,n,n,(stuff....)

Basically I need to replace the first occurrence of x with u then the rest with n. This part I was able to do. Then I need to remove the last letter from the pattern (n or m) and leave the rest. Is there some way I can search for say ,.,.,.,.,., and then remove the last ., without knowing what character it will be or which occurrence. Say read the pattern into a variable and then remove the last character through its index or something.

Thanks for any help on figure this out

D
 

Bookmarks

Tags
replace, sed, shell

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 11:46 AM.


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