The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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.

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 4 Days Ago
mhdmehraj mhdmehraj is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 6
Using Sed

Hi ,

i need to insert a backslash (/) after all the occurances of semi colon ( in a file .

How to do it using Sed command
  #2 (permalink)  
Old 4 Days Ago
thegeek thegeek is offline
Registered User
  
 

Join Date: Apr 2009
Location: /usr/bin/vim
Posts: 431
Code:
$ cat t1
se:mi:co:lons::: here:: and there.
$ sed 's@:@:\\@g' t1
se:\mi:\co:\lons:\:\:\ here:\:\ and there.
Yep, you have mentioned backslash, and given front slash... ok anyway.. for front slash no need to escape that.
Code:
$ sed 's@:@:/@g' t1
se:/mi:/co:/lons:/:/:/ here:/:/ and there.
  #3 (permalink)  
Old 4 Days Ago
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,502
bash
Code:
$ while read -r line ; do echo ${line//:/:\/}; done< file > newfile
gawk
Code:
awk -vFS=":" '{$1=$1}1' OFS=":/" file
  #4 (permalink)  
Old 4 Days Ago
mhdmehraj mhdmehraj is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 6
Hi ,


I need that slash to be printed in the next line whenever it founds a semicolon
  #5 (permalink)  
Old 4 Days Ago
rdcwayx rdcwayx is online now
Registered User
  
 

Join Date: Jun 2006
Posts: 194
Code:
sed  '/:/a\/' urfile
  #6 (permalink)  
Old 4 Days Ago
Scrutinizer Scrutinizer is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 584
Code:
sed 's#;#;\n/#g' infile

BTW Shouldn't the example above be:
Code:
echo 'se:mi:co:lons::: here:: and there'|sed 's/:/;/g'
Sponsored Links
Reply

Bookmarks

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 02:40 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