Removing special characeter "~V" in a unix file

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Removing special characeter "~V" in a unix file
# 1  
Old 10-20-2009
Removing special characeter "~V" in a unix file

I have the Unix XML file as below:
<?xml version="1.0" encoding="UTF-8"?>
<ReportData version="1.0"><DisplayName>Non-Agency CMO Daily Trade Recap - Hybrids</DisplayName><ReportType>MgmtTradingReport</ReportType><Description>Management Trading reports</Description><AsOfDate>10/20/2009</AsOfDate><PublishedDate>10/20/2009</PublishedDate><IsEmailable>false</IsEmailable><Authors><Author>Desk</Author></Authors><ReportFiles><File>/RER/bas/reports/MgmtReporting/Trading/NonAgency CMO/20091020.Non-Agency CMO Daily Trade Recap ~V Hybrids.pdf</File></ReportFiles></ReportData>

I have to replace "~V" with "-", I used sed command to replace but was only able to replace "" with a blank, since "~V" is a special characeter may be combination of some keys even sed command is unable to find this.

When i cat this file i do not see "~V", but see this when i open this file in Vi editor.

I want to get rid of this "~V", please help !
# 2  
Old 10-20-2009
Try to use <CTRL-V> or <ESC> to escape your special character
# 3  
Old 10-20-2009
Dude, I already tried it... no use.. ctlr is "^" in vi editor.
# 4  
Old 10-20-2009
What command/s have you tried so far?
# 5  
Old 10-20-2009
sed 's/~V/-/' "filename"

But this dosnt work,since sed is unable to find ~V, also I cannot see this character when i cat this file, only i see this in vi editor, as an highlighted one.

I also tried > this file into another, but still this is propogated, I dont want ot se this in vi editor..
# 6  
Old 10-20-2009
You could perhaps try using the surrounding patterns and use the . character for the number of obscure characters in the middle. E.g. if you need to replace 2 characters:
sed 's/\(Recap \)..\( Hybrids\)/\1-\2/' xmlfile

# 7  
Old 10-20-2009
If you have the xxd utility available (part of vim I think), pipe the file into it. Take the hexadecimal code for the strange character, convert it to octal, and the you can use command substitution + echo to have sed remove it.

$ cat test.txt # As seen by vi
This is a ~V test
$ cat test.txt | xxd
0000000: 5468 6973 2069 7320 6120 c296 2074 6573  This is a .. tes
0000010: 740a                                     t.
$ echo "ibase=16; obase=8; 96" | bc
$ cat test.txt | sed -e 's/'$( echo -e '\0226' )'//g'
This is a  test

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

Removing duplicates on a single "column" (delimited file)

Hello ! I'm quite new to linux but haven't found a script to do this task, unfortunately my knowledge is quite limited on shellscripts... Could you guys help me removing the duplicate lines of a file, based only on a single "column"? For example: M202034357;01/2008;J30RJ021;Ciclo 01... (4 Replies)
Discussion started by: Rufinofr
4 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing To e-mail address and column 3 contains cc e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. Shell Programming and Scripting

Need HELP with AWK split. Need to check for "special characters" in string before splitting the file

Hi Experts. I'm stuck with the below AWK code where i'm trying to move the records containing any special characters in the last field to a bad file. awk -F, '{if ($NF ~ /^|^/) print >"goodfile";else print >"badfile"}' filename sample data 1,abc,def,1234,A * 2,bed,dec,342,* A ... (6 Replies)
Discussion started by: shell_boy23
6 Replies

5. Shell Programming and Scripting

Removing "^M" from the end of a String (i.e. "Ctrl+M")?

Hello All, I have an Expect script that ssh's to a remote server and runs some commands before exiting. One of the commands I run is the "hostname" Command. After I run this command I save the output using this line in the code below... Basically it executes the hostname command, then I... (2 Replies)
Discussion started by: mrm5102
2 Replies

6. UNIX for Dummies Questions & Answers

Unix "look" Command "File too large" Error Message

I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this: $ look "string" "/home/patrick/filename.txt" However, this gives me the following message: "look: /home/patrick/filename.txt: File too large" So, I have two... (14 Replies)
Discussion started by: shishong
14 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. Shell Programming and Scripting

Question about special variables: "-" and "$_"

both ksh/bash support this 2 special variables, Is there any document for reference? 1) "-" is $OLDPWD 2) "$_" is last argument of previous command. (4 Replies)
Discussion started by: honglus
4 Replies

9. UNIX for Advanced & Expert Users

Commands on Digital Unix equivalent to for "top" and "sar" on other Unix flavour

Hi, We have a DEC Alpha 4100 Server with OSF1 Digital Unix 4.0. Can any one tell me, if there are any commands on this Unix which are equivalent to "top" and "sar" on HP-UX or Sun Solaris ? I am particularly interested in knowing the CPU Load, what process is running on which CPU, etc. ... (1 Reply)
Discussion started by: sameerdes
1 Replies
Login or Register to Ask a Question