Visit Our UNIX and Linux User Community


sed file problems


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers sed file problems
# 1  
Old 04-08-2002
sed file problems

when i am running a sed command i want to get rid of all of the backslashes in the lin but it is taking this as being a command how do i delete backslashes?????

sed -e "s/\/g"

Anyn ideas?????????

Last edited by johnnynolegs; 04-08-2002 at 08:24 AM..
# 2  
Old 04-08-2002
Bug

try this
sed 's/\\//g' file1.out > file2.out
# 3  
Old 04-08-2002
Data

i tried that already but it did not work :-( - ended up doing it in a text file which worked but would really like to know how to do it using sed..................
# 4  
Old 04-08-2002
you do not need to user a / as the delimiter for your sed statement, try using the = so your sed command looks like this

sed -e "s=\==g" file1 > file2
# 5  
Old 04-08-2002
Here is a good solution.

cat filename.in |sed 's/\\//g' > newfilename.out

I know this is similar to one post already but I just tested it and it worked for me in ksh on HPUX box.


root> cat file
\todd \qasd \adrladf

root> cat file |sed 's/\\//g' > (your output file here)
todd qasd adrladf


It removes the backslashes. It even works when I concat all of the "words" together or even with multiple consecutive \\ in a file.



Smilie
# 6  
Old 04-08-2002
Quote:
Originally posted by Kelam_Magnus
Here is a good solution.

cat filename.in |sed 's/\\//g' > newfilename.out

Useless Use of Cat. Simplify to:

sed 's/\\//g' filename.in > filename.out

Last edited by Perderabo; 12-13-2006 at 09:04 AM.. Reason: Update UUOC URL
# 7  
Old 04-08-2002
Yes, I realized that it was.

However, he said that he already tried it that way. I was just trying to offer an alternative. Possibly there is a problem on his box.

Now that I look at it, he may have been using double quotes which may have made sed take it as a literal.

Try to limit extra commands, but I like to eliminate any variation as a bug.
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #495
Difficulty: Easy
Blocks of code cannot be nested within each other to form sub-blocks.
True or False?

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Execution Problems with sed

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Okay so I am taking bash scripting this semester and we are now working on the stream editor sed. For our book we... (4 Replies)
Discussion started by: aggie6970
4 Replies

2. UNIX for Advanced & Expert Users

problems with sed

$ echo "a,0,0,0,b,0" | sed 's/,0,/,1,/g' gives output as $ a,1,0,1,b,0 rather than as a,1,1,1,b,0 how can i solve this problem Thanks a lot in advance.... Use code tags. (4 Replies)
Discussion started by: manishma71
4 Replies

3. Shell Programming and Scripting

2 problems... sed and sort

Hi everyone! I have a file like that: And I would it like that: I don't know how to keep the first field and sort the second one. I have a second question with sed... to put the variable $VAR at the beginning of the file... But I have an output like this: snork... (3 Replies)
Discussion started by: Castelior
3 Replies

4. Shell Programming and Scripting

problems using sed

i have a file acc.sh which has about 10 lines and then i have defined $var which has a line number in it (say 5). i want to extarct from line 5 to the end of the file and put the output into another file. I have used sed -n $var,'$p' acc.sh | tee abc.sh but at times it does'nt work and gives an... (6 Replies)
Discussion started by: lassimanji
6 Replies

5. Solaris

Sed problems on Solaris 10

Hi, The config file: # Port(s) for accepting client connections RTSPPort=554 bash-3.00# awk -F"=" -v gr="888" '/RTSPPort/{$2=gr;}1' OFS="=" server.ini awk: syntax error near line 1 awk: bailing out near line 1 Can you help me on why this doesn't work. The next one neighter. Dosn't... (0 Replies)
Discussion started by: potro
0 Replies

6. Shell Programming and Scripting

Having problems with sed: can't replace $1

At the moment, I'm trying to do the following: 1. Have sed read the first line of a file Example (file1.x): 5 2. Replace that first line with a new first line, which would read 5=newvariable 3. Have that information placed into file2.y Unfortunately, I'm having a problem. Sed... (5 Replies)
Discussion started by: Agent-X
5 Replies

7. UNIX for Dummies Questions & Answers

Problems with sed and flat file variables

Hello All, It has been a loooooooooooong time since I had last used sed but decided to use it for a simple task I have . My goal is to use sed to read variables from a flat file then use those same variables in order to make some subsitutions. However what I am finding is that when the... (1 Reply)
Discussion started by: icalderus
1 Replies

8. Shell Programming and Scripting

Problems with SED

I have a group of xml files and I need to insert 3 parameters just after this line in each file: ---------------Pattern to be searched for------------------------- <!--The following configuration is a test configuration--> ---------------Parameters to be added---------------------------... (11 Replies)
Discussion started by: collern2
11 Replies

9. UNIX for Dummies Questions & Answers

Problems with sed

Hi, I'm trying to use the sed command but I'm not sure how to use it properly. I've read the man pages for the sed command but I'm still unsure on how to use it. Basically I have a file with the words male and female written multiple times. I want to swap the word male for female and... (4 Replies)
Discussion started by: tugade
4 Replies

10. Shell Programming and Scripting

sed substitution problems

Hi falks, I need to substitute in my ksh program, parameter (full path of directory) ,which is sent from outside program, with another parameter (another full path of directory) ,which is known and validated inside my program. I tried to use "sed" ,but i failed. For example: ... (2 Replies)
Discussion started by: nir_s
2 Replies

Featured Tech Videos