remove special character from a textfile


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting remove special character from a textfile
# 1  
Old 10-14-2009
remove special character from a textfile

Can any one plse help me writing shell script to removing some special character pattern (like / > -------, / > / > ------- etc....as shown below) from the text file ASAP.

Code:
/ >  -------
<tag-normalization tag-name="EXECSERVPRODUCT" read-only="false" part="body">
                                <mapping-condition/>
                                <mapping-expression>
                                        <expression value="$6061"/>
                                </mapping-expression>
                        </tag-normalization>
/ > / >  -------
<tag-normalization tag-name="STARTTIME" read-only="false" part="body">
                                <mapping-condition/>
                                <mapping-expression>
                                        <expression value="$6062"/>
                                </mapping-expression>
                        </tag-normalization>
/ > / >  -------
<tag-normalization tag-name="ENDTIME" read-only="false" part="body">
                                <mapping-condition/>
                                <mapping-expression>
                                        <expression value="$6063"/>
                                </mapping-expression>
                        </tag-normalization>
/ > / >  -------


Last edited by Yogesh Sawant; 10-14-2009 at 09:40 AM.. Reason: added code tags
# 2  
Old 10-14-2009
Code:
#! /bin/ksh
grep -v "/ >" c.txt >> new.txt

# 3  
Old 10-14-2009
Thanx Amit for your quick reply
# 4  
Old 10-14-2009
Ouput in stdout,

Code:
$sed  '/\/ > -\+/d' filename

The input file will be overwritten in the below solution.


Code:
$ sed  -i.bak '/\/ > -\+/d' a
$ cat a
<tag-normalization tag-name="EXECSERVPRODUCT" read-only="false" part="body">
<mapping-condition/>
<mapping-expression>
<expression value="$6061"/>
</mapping-expression>
</tag-normalization>
<tag-normalization tag-name="STARTTIME" read-only="false" part="body">
<mapping-condition/>
<mapping-expression>
<expression value="$6062"/>
</mapping-expression>
</tag-normalization>
<tag-normalization tag-name="ENDTIME" read-only="false" part="body">
<mapping-condition/>
<mapping-expression>
<expression value="$6063"/>
</mapping-expression>
</tag-normalization>

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Remove a word that ends with special character "!"

Hi all. I want to use sed to remove a word that ends with "!" in the first page of a file. The word I want to remove is: "DNA!". I have search for an answer and nothing of what I found helped me. ~faizlo (2 Replies)
Discussion started by: faizlo
2 Replies

2. Shell Programming and Scripting

Remove word after special character "/"

Hi There, I have one requirement to remove word after character "/". Input file is 2017-07-12|02|user1l|domain1/userl|0 2017-07-12|02|user2|domain1/user2|5 2017-07-12|02|user3|domain2/user3|0 2017-07-12|02|user4|domain1/user4|432 and require OP file is ... (2 Replies)
Discussion started by: anshu ranjan
2 Replies

3. Shell Programming and Scripting

How to separate sorte different characters from one textfile and copy them in a new textfile?

My first post, so don't kill me :) Say i open some textfile with some example like this. on the table are handy, bread and wine Now i know exactly what is in and i want to separate and sorted it in terminal to an existing file with another 2 existing lines in like this: table plane ... (3 Replies)
Discussion started by: schwatter
3 Replies

4. Shell Programming and Scripting

Remove blank space and insert special character

Hi Folks, I have a huge data of the below format abc #apple 1200 06/23 ghj #orange 1500 06/27 uyt #banana 2300 05/13 efg #vegetable 0700 04/16 After first 3 letters, i have 9 spaces and after fruit there are no specific fixed space, but it varies... (4 Replies)
Discussion started by: jayadanabalan
4 Replies

5. Shell Programming and Scripting

Remove some special ascii character

Hello I have this special caracter after retreving rows from sql server: "....spasses: • Entrem al valort 6050108002811 • El donem..." I would like a sed command to remove it..or just know it's ascii code in order to replace it into my sql sentence.. Hope some one knows how to do that.... (7 Replies)
Discussion started by: ldiaz2106
7 Replies

6. Shell Programming and Scripting

Remove special character ($) from file names

Hello I've searched here and on the 'net for examples of a script or command line function that will remove the $ character from all file names only that can be done within the directory that contains the file names - which are all html files. ie, I have a directory that contains html files... (6 Replies)
Discussion started by: competitions
6 Replies

7. Shell Programming and Scripting

remove special character from a specific column

Hello , i have a text file like this : A123 c12AB c32DD aaaa B123 23DS 12QW bbbb C123 2GR 3RG cccccc i want to remove the numbers from second and third column only. i tried this : perl -pe 's///g' file.txt > newfile.txt but it will remove the number from... (7 Replies)
Discussion started by: shelladdict
7 Replies

8. Shell Programming and Scripting

Deleteing one character after an special character

I have below line in a unix file, I want to delete one character after "Â". 20091020.Non-Agency CMO Daily Trade Recap Â~V Hybrids The result should be : 20091020.Non-Agency CMO Daily Trade Recap  Hybrids i dont want to use "~V" anywhere in the sed command or any other command, just remove... (1 Reply)
Discussion started by: mohsin.quazi
1 Replies

9. Shell Programming and Scripting

Remove box like special character from end of string

Hi All, How to remove a box like special character which appears at the end of a string/line/record. I have no clue what this box like special character is. It is transparent square like box. This appears in a .DAT file at the end of header. I'm to compare a value in header with a parameter.... (16 Replies)
Discussion started by: Qwerty123
16 Replies
Login or Register to Ask a Question