Replace slash / with space


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Replace slash / with space
# 1  
Old 07-01-2010
Replace slash / with space

Hello there everyone. would like to ask for help if i wish to replace a slash / with space using sed.

Original:
Code:
T/T

Result:
Code:
T T

hope someone could help me up, thanks

Charles

Last edited by Don Cragun; 09-15-2015 at 05:36 AM.. Reason: Add CODE tags.
# 2  
Old 07-01-2010
Code:
$ echo 'T/T' | sed 's/\// /'
T T
$

or
Code:
$ echo 'T/T' | sed 's!/! !' 
T T
$

# 3  
Old 07-01-2010
Quote:
Originally Posted by pseudocoder
Code:
$ echo 'T/T' | sed 's/\// /'
T T
$

or
Code:
$ echo 'T/T' | sed 's!/! !' 
T T
$

thanks for the reply. i am wondering how do i do that if the T/T is in a large file with continuous value
for example:

myfile.txt
Code:
T/T R/R B/B T/T

and need the result file of:
Code:
T T R R B B T T



---------- Post updated at 05:46 AM ---------- Previous update was at 05:35 AM ----------

can sed 's/\// /' myname >newfile work?

Last edited by Don Cragun; 09-15-2015 at 05:35 AM.. Reason: Add CODE AND ICODE tags.
# 4  
Old 07-01-2010
Quote:
Originally Posted by seiksoon
can
Code:
sed 's/\// /g' myname >newfile

work?
Should work, but add a "g", for global replacement, else only the first match per line gets changed and not all.
# 5  
Old 07-02-2010
Code:
(03:09:31\[D@DeCoBox15)
[~]$ echo "T/T R/R B/B T/T"|tr / " "
T T R R B B T T

tr - translate characters. sed will do the job wonderfully, but for simple things like replacing a single character, I go with tr.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Replace string until 3Rd occurance of forward slash(/)

I have a file abc.txt which has records like 456 /home/fgg/abdc.txt 3567 /home/fdss/vfgb.txt 23 /home/asd/dfght.txt I WANT TO REMOVE STRING UNTIL 3RD OCCURANCE OF FORWARD SLASH Output should be like abdc.txt vfgb.txt dfght.txt (5 Replies)
Discussion started by: himanshupant
5 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

Replace long space to become one space?

Hi, i have the log attached. Actually i want the long space just become 1 space left like this : Rgds, (12 Replies)
Discussion started by: justbow
12 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. UNIX for Advanced & Expert Users

Substitute single backward-slash with the double backward-slash

Hi, I have a path like this c:\test\sample\programs, i need to change thiis to c:\\test\\sample\\programs. How to perform this? I tried tr command but it didn't help me. Thanks Vijayan (3 Replies)
Discussion started by: mvictorvijayan
3 Replies

9. Shell Programming and Scripting

replace space by _

Hi I need to know how I change the spaces by _ in folders and filder founded by find ex. find . -name "* *" -exec echo {} \; ./test space ./test space/new file.txt ./test space/new file ./test space/untitled folder ./test space/untitled folder/new fileruben ./Backup/backup/Image... (6 Replies)
Discussion started by: ruben.rodrigues
6 Replies

10. Shell Programming and Scripting

Replace the last slash alone

Hi All, Can you please help me with the below issue. I want only the last slash to be replaced with space. 06/05/2008/EDED_FD_BDCD_ABCD_123 06/05/2008 EDED_FD_BDCD_ABCD_123 (3 Replies)
Discussion started by: christineida
3 Replies
Login or Register to Ask a Question