|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Using sed to replace / in text file
Hi, I want to use sed to replace " /// " with "///" in a text file. However I am getting error messages when I use PHP Code:
Input: Code:
219518_s_at 0.000189 ELL3 / SERINC4 Output: Code:
219518_s_at 0.000189 ELL3/SERINC4 |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Code:
sed 's/ \/ /\//g' infile >outfile |
| The Following User Says Thank You to jim mcnamara For This Useful Post: | ||
evelibertine (06-27-2012) | ||
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Sorry about the confusion, the smaple input should have been: Code:
219518_s_at 0.000189 ELL3 /// SERINC4 and the sample output: Code:
219518_s_at 0.000189 ELL3/SERINC4 Thanks! |
|
#4
|
|||
|
|||
|
You can use a ':' in place of a '/' to avoid confusions. Code:
sed 's: ///:///:g' input.txt > output.txt |
| The Following User Says Thank You to prithvirao17 For This Useful Post: | ||
evelibertine (09-11-2012) | ||
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
Code:
$ sed 's, /// ,/,g' infile |
| The Following User Says Thank You to jayan_jay For This Useful Post: | ||
evelibertine (09-11-2012) | ||
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Code:
sed 's| *//* *|/|g' |
| The Following User Says Thank You to Scrutinizer For This Useful Post: | ||
evelibertine (09-11-2012) | ||
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Replace char on text file | phillipss | Shell Programming and Scripting | 2 | 12-11-2010 12:19 AM |
| search and replace a text in a file | goutam_igate | Shell Programming and Scripting | 5 | 04-27-2009 06:03 AM |
| How to replace text in a file with text entered | cleanden | Shell Programming and Scripting | 9 | 04-11-2009 08:03 PM |
| how can search a String in one text file and replace the whole line in another file | kkraja | UNIX for Dummies Questions & Answers | 6 | 08-06-2008 07:23 AM |
| search and replace a specific text in text file? | santosham | UNIX for Dummies Questions & Answers | 4 | 06-25-2008 05:53 PM |
|
|