remove backslash character from file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting remove backslash character from file
# 1  
Old 08-11-2009
remove backslash character from file

How do I remove a backslash character \ from a file?

I have used
Code:
sed -e "s|\||g" filename > newfile

I have done several permutations on this to no avail such as:

Code:
sed -e "s|`\`||g" filename > newfile
sed -e "s|""\""||g" filename > newfile

What am I doing wrong?Smilie

Thanks in advance

Last edited by rbatte1; 07-07-2016 at 12:27 PM.. Reason: Code tags
# 2  
Old 08-11-2009
Code:
 sed 's/\\//g' filename >newfile

You have escape a backslash by adding an escape character - the backslash
# 3  
Old 08-12-2009
Worked like a charm, thanks so much.Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove newline character if it is the only character in the entire file.?

I have a file which comes every day and the file data look's as below. Vi abc.txt a|b|c|d\n a|g|h|j\n Some times we receive the file with only a new line character in the file like vi abc.txt \n (8 Replies)
Discussion started by: rak Kundra
8 Replies

2. Shell Programming and Scripting

Replace special characters with backslash and character

Hi, I have a string wherein i need to replace special characters with backslash and that character. Ex: If my string is a=qwerty123@!, then the new string should be a_new=qwerty123\@\!\, Thanks (3 Replies)
Discussion started by: temp_user
3 Replies

3. Shell Programming and Scripting

How to remove hidden backslash in multiple files?

Hi I have around 300 files in a folder. When I type ls -l I see the following Mouse.chr10_+_:101862321-101863928.maf Mouse.chr10_+_:101862322-101863928.maf Mouse.chr10_+_:101862323-101863928.maf But when I run my scripts, they couldn't recognise the filename because of hidden backslash like... (5 Replies)
Discussion started by: quincyjones
5 Replies

4. Shell Programming and Scripting

Passing backslash character to awk variable

Hi All. I have a file that contains some special characters and I'm trying to use AWK to search for lines between <pattern1> and <pattern2>. As an example: I need the lines between the line containing ' select_id="x_0 ' and the line containing the next instance of ' from '. This is a file... (5 Replies)
Discussion started by: Mudshark
5 Replies

5. Shell Programming and Scripting

Remove ^L character from a file

Hello, I need to remove ^L character from a file as below: HELLO "I " HELLO "I " ^L HELLO "I" HELLO "I " HELLO "I " Please suggest. Thanks !! Please use next time code tags for your code and data (9 Replies)
Discussion started by: skhichi
9 Replies

6. UNIX for Dummies Questions & Answers

Remove tab character from file

I am trying to remove the tab character from a file, which occurs on two places in every line. So far I have tried the following and most are from threads in this forum: sed -i '' -e 's/ / /' file.dat sed -i '' -e 's/*/ /' file.dat sed -i '' -e 's/\t*/ /g' file.dat sed -i '' -e 's/*//g'... (4 Replies)
Discussion started by: figaro
4 Replies

7. Shell Programming and Scripting

How to remove the ^@ character in a file.

I receive a file which is Dos format. When I view the file using vi, I was able to find ^M, ^@ characters in beteen records. I wanted to remove these control/special characters. I used the dos2unix command. This removed the ^M characters. But I am unable to remove the ^@ character. I tried even the... (6 Replies)
Discussion started by: machomaddy
6 Replies

8. Shell Programming and Scripting

How to remove first 2 character from file name

Hi All Please help me to remove the first 2 character from the file name. files are like this $ ls 12aman file 13atul si 56rana se I want to remove the first 2 char which are numbers. I want the o/p like thus aman file atul si rana se (8 Replies)
Discussion started by: atul9806
8 Replies

9. HP-UX

How to remove new line character and append new line character in a file?

Hi Experts, I have data coming in 4 columns and there are new line characters \n in between the data. I need to remove the new line characters in the middle of the row and keep the \n character at the end of the line. File is comma (,) seperated. Eg: ID,Client ,SNo,Rank 37,Airtel \n... (8 Replies)
Discussion started by: sasikari
8 Replies

10. Shell Programming and Scripting

How ro handle backslash character in grep?

Hi , I am doing invert grep using -v but the string contain "/" which break the grep command and it do not skip the lines with "/" on it. Diffu.txt ======== 1159c1159 < <td align="right" valign="middle" class="paddingRight2px" id="featureListItemChannelButton7466"> --- > <td... (1 Reply)
Discussion started by: rajbal
1 Replies
Login or Register to Ask a Question