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


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

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 05-24-2012
Registered User
 
Join Date: May 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
sed command

Hi All ,

could you please let me know hoe the following command is working!!!

Code:
sed 's[^./[[g'

Thanks
Preetpal

Last edited by Franklin52; 05-24-2012 at 03:28 AM.. Reason: Please use code tags
Sponsored Links
    #2  
Old 05-24-2012
guruprasadpr's Avatar
Shrink...ing
 
Join Date: Jun 2009
Location: India
Posts: 674
Thanks: 30
Thanked 215 Times in 214 Posts
Hi

Used to remove ./ from the beginning of a variable:



Code:
$ echo ./abc/efg/hij
./abc/efg/hij

sed:

Code:
$ echo ./abc/efg/hij | sed 's[^./[[g'
abc/efg/hij

Sponsored Links
    #3  
Old 05-24-2012
clx clx is offline Forum Advisor  
Registered User
 
Join Date: Jun 2007
Location: Mumbai,India
Posts: 1,417
Thanks: 101
Thanked 133 Times in 129 Posts
Quote:
Originally Posted by preetpalkapoor View Post
Hi All ,

could you please let me know hoe the following command is working!!!

Code:
sed 's[^./[[g'

Thanks
Preetpal

It'd actually remove any character followed by "/" at the beginning.

e.g.


Code:
$ echo //abc/efg/hij | sed 's|^./||g'
abc/efg/hij
$ echo a/abc/efg/hij | sed 's|^./||g'
abc/efg/hij

To remove "./" you must escape the ".".



Code:
echo ./abc/efg/hij | sed 's[^\./[[g'

You could use any other symbol instead of "[" if it looks weird.

Code:
echo ./abc/efg/hij | sed 's|^./||g'

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
passing command output from one command to the next command in cshell kaaliakahn UNIX for Dummies Questions & Answers 2 02-10-2012 04:59 PM
unix command : how to insert text at the cursor location via command line? xib.be UNIX for Advanced & Expert Users 0 12-22-2010 05:45 PM
Need help! command working ok when executed in command line, but fails when run inside a script! 4dirk1 Shell Programming and Scripting 4 12-02-2010 05:47 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
assign a command line argument and a unix command to awk variables sweta_doshi Shell Programming and Scripting 0 08-08-2008 06:54 AM



All times are GMT -4. The time now is 01:13 AM.