sed Command | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

sed Command

Shell Programming and Scripting


Tags
sed

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 04-17-2013
emilioveras emilioveras is offline
Registered User
 
Join Date: Apr 2013
Last Activity: 18 April 2013, 9:59 AM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Code sed Command

Hello,

I'm working with this command which I'm having trouble understanding it:


Code:
sed -e '1,$ s/SUB/N/g' < $1 > file.txt

Where SUB stand for an special character with code in ASCII is 0x1A, notepad read it as a right arrow.

Any help will be appreciated.
Sponsored Links
    #2  
Old 04-17-2013
hanson44 hanson44 is offline
Registered User
 
Join Date: Mar 2013
Last Activity: 12 May 2013, 11:33 PM EDT
Posts: 858
Thanks: 18
Thanked 180 Times in 177 Posts
What do you mean "stands for a special character"? "SUB" is just "SUB", the three letters. Are you trying to substitute for 0x1a?
Sponsored Links
    #3  
Old 04-17-2013
mirni mirni is offline
Registered User
 
Join Date: Mar 2011
Last Activity: 2 October 2014, 3:08 AM EDT
Posts: 686
Thanks: 51
Thanked 178 Times in 171 Posts
1,$ line range; apply the following command on all lines ('$' in this context means last line). This part can be omitted since the full range is default.
s/foo/bar/g substitute (s) 'foo' with 'bar', globally (g), which means all instances of 'foo' will be replaced with 'bar'. Any delimiter can be used (useful if your expression contains slashes), e.g. s!foo!bar!g
<$1 feed input to sed from first positional argument ($1)
> file.txt and write it to file.txt
    #4  
Old 04-17-2013
hanson44 hanson44 is offline
Registered User
 
Join Date: Mar 2013
Last Activity: 12 May 2013, 11:33 PM EDT
Posts: 858
Thanks: 18
Thanked 180 Times in 177 Posts
My guess is you are trying to do the following:

Code:
$ tr "\032" "N" < test
N

\032 (same as \0x1A) gets changed to N
Sponsored Links
    #5  
Old 04-17-2013
alister alister is offline
Registered User
 
Join Date: Dec 2009
Last Activity: 11 June 2014, 8:40 PM EDT
Posts: 3,231
Thanks: 179
Thanked 973 Times in 789 Posts
Quote:
Originally Posted by hanson44 View Post
What do you mean "stands for a special character"? "SUB" is just "SUB", the three letters. Are you trying to substitute for 0x1a?
Substitute character aka Control-Z (suspends in UNIX, EOF in DOS).

Regards,
Alister

Last edited by alister; 04-17-2013 at 11:25 PM..
The Following User Says Thank You to alister For This Useful Post:
mirni (04-18-2013)
Sponsored Links
    #6  
Old 04-18-2013
emilioveras emilioveras is offline
Registered User
 
Join Date: Apr 2013
Last Activity: 18 April 2013, 9:59 AM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you very much for your replays. mirni your post was very explanatory.
Sponsored Links
Closed Thread

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
sed returns error "sed: -e expression #1, char 18: unterminated `s' command" anand.shah Shell Programming and Scripting 8 10-15-2012 09:53 AM
sed insert command and variable expansion/command substitution glev2005 UNIX for Dummies Questions & Answers 8 03-09-2010 02:18 PM
Convert Sed command to perl command abacus Shell Programming and Scripting 2 11-10-2009 11:25 AM
Loop with sed command to replace line with sed command in it cbo0485 Shell Programming and Scripting 1 08-27-2009 11:19 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 12:29 PM



All times are GMT -4. The time now is 03:41 PM.