Passing slash with sed: failure


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Passing slash with sed: failure
# 1  
Old 05-03-2012
Passing slash with sed: failure

Hi,
I have a text file with the normal text like:
Code:
rfio://castor/cern.ch/user/p/pooja/WorkArea/Fall11/QCD/QCD800To1000/bkg_40_2_yOo.root

I want to make shell script which ask for the word to replace where it sud take "'/" variable as well. And change it to the pattern I need.

Here in the above code, I want to replace "\\" with "\" . So the code would be like:
Code:
 rfio:/castor/cern.ch/user/p/pooja/WorkArea/Fall11/QCD/QCD800To1000/bkg_40_2_yOo.root

But unsuccessful in doing it so far.

Any help would mean alot.

Many Thanks
Pooja
# 2  
Old 05-03-2012
Try:
Code:
sed s://:/:

# 3  
Old 05-03-2012
Code:
echo "rfio://castor/cern.ch/user/p/pooja/WorkArea/Fall11/QCD/QCD800To1000/bkg_40_2_yOo.root" | sed 's/\/\//\//g'
rfio:/castor/cern.ch/user/p/pooja/WorkArea/Fall11/QCD/QCD800To1000/bkg_40_2_yOo.root

Moderator's Comments:
Mod Comment Please click this link: How to use [code][/code] tags
# 4  
Old 05-09-2012
thanks for the help..Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed not working properly with slash /

my testfile is aspsun1:usasp000$cat testfile open connection put $TMPDIR/SUNIA.PJ080202.ENGRPTBZ.<OPERATOR>.133 <FILENAME> quit my problem statement is to replace the line with put command with 2 different lines a cd command and then put line. from put... (2 Replies)
Discussion started by: gotamp
2 Replies

2. Shell Programming and Scripting

sed command to replace slash in date format only

Hello experts. I haven't been able to find a solution for this using the sed command. I only want to replace the forward slash with string "FW_SLASH" only if there's a number right after the slash while preserving the original number. I have a file containing 2 entries: Original File:... (5 Replies)
Discussion started by: pchang
5 Replies

3. Shell Programming and Scripting

AWK or SED to replace forward slash

hi hope somebody can help, there seems to be bit on the net about this, but still cant make it work the way i need. i have a file live this mm dd ff /dev/name1 mm dd ff /dev/name2 mm dd ff /dev/name3 mm dd ff /dev/name4 i need to update /dev/name1 etc to /newdev/new/name1 etc so... (5 Replies)
Discussion started by: dshakey
5 Replies

4. UNIX for Dummies Questions & Answers

Replace Forward Slash with sed

i need to replace '/' forward slash with \/(backward slash follwed by a forward slash) using sed command when the forward slash occurs as a first character in a file.. Tried something like this but doesn't seem to work. find $1 -print0 | xargs -0 sed -i -e 's/^\//\\\//g' Can someone... (19 Replies)
Discussion started by: depakjan
19 Replies

5. Shell Programming and Scripting

sed to insert a slash and keep text

I have: /path/to/my/fixdir/MD1234567.tar I want to have: /path/to/my/fixdir/MD/1234567.tar fixdir never changes but MD does and how many numerical digits does. I want something like: /usr/bin/sed 's/fixdir\/../fixdir\/..\//' This ends up: /path/to/my/fixdir/../1234567.tar But... (3 Replies)
Discussion started by: crowman
3 Replies

6. Shell Programming and Scripting

How to replace comma by slash using sed in an UTF8 file

Hello all, I'd like to replace "," by "/" in a utf8 file from postion X to Y. Comma "," is also defined as delimiter. 12345678901234567890,123456789012345,12345678901234567890, aaaa,aaaa,aaaaa ,bbb,bbbb,bbbbb ,cccccc,cc , Result should be... (1 Reply)
Discussion started by: fmofmo
1 Replies

7. Shell Programming and Scripting

Using sed to append backward slash before forward slash

Hi all, I need to know way of inserting backward slash before forward slash. My problem is that i need to supply directory path as an argument while invoking cshell script. This argument is further used in script (i.e. sed is used to insert this path in some file). So i need to place \ in front... (2 Replies)
Discussion started by: sarbjit
2 Replies

8. Shell Programming and Scripting

Problem in sed because of multiple /(slash)

Hi All, My target is to replace the text in a file.txt to newword, say "singleslash" to "double/slash/" NOTE: The replacing word itself contains the symbol /(slash). here is my code sed "s/singleslash/double/slash//g" file.txt . Will this properly substitute the new word... (6 Replies)
Discussion started by: Arunprasad
6 Replies

9. Shell Programming and Scripting

How to parse slash / in sed command..

Hi All, I am trying to replace paths with \ (as in NT) with / (as in Unix) in a script using sed. Following is the command I use: sed "s/e:\Kenny_test\csv_files/var/opt/ciw/data/outbound/g" EMEA4710.SQL > test the string to replace is e:\Kenny_test\csv_files the target string needs to... (3 Replies)
Discussion started by: Abhidey
3 Replies

10. Shell Programming and Scripting

Help with SED and forward slash

Using the script: (Called replaceit) #!/bin/ksh String=$1 Replace=$2 sed -e "s/${orig}/${new}/g" oldfile.txt > newfile.txt In oldfile.txt, I'm looking for: getenv("Work") And change it To: /u/web I execute the script: replaceit "getenv(\""Work\"")" /u/web I'm getting sed... (3 Replies)
Discussion started by: gseyforth
3 Replies
Login or Register to Ask a Question