How to remove degree symbol from the TXT files?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to remove degree symbol from the TXT files?
# 1  
Old 09-25-2011
Java How to remove degree symbol from the TXT files?

I have TXT files[2000] to process but they contain the degree symbols in them due to which the processing program fails on these files. I want a unix command that will remove the degree symbols from these files.

I tried using the sed command: sed 's/[!@#\$%^°&*()]//g' filename but it did not work. This issue requires immediate attention at my end, any help on this would be highly appreciated.

Khedu.
# 2  
Old 09-26-2011
What did not work? The sed command looks good, but you need either:
  • to redirect the output produced by sed to a file, or
  • to change in place using the option '-i'. I recommend to make a backup of the files before doing this, just to play safe.
Cheers,
/Lew
# 3  
Old 09-26-2011
The above used sed command doesn't replace the degree symbols from the text files even with -i option. Help required on this..
# 4  
Old 09-26-2011
try this..

Code:
 
perl -i -pe 's/[^\u2103]//g' file

# 5  
Old 09-26-2011
sed

Quote:
Originally Posted by khedu
The above used sed command doesn't replace the degree symbols from the text files even with -i option. Help required on this..

Hi,

if you unable to substitute, try to use \ before that symbol bcos those symbols have special meaning.

\ - refers take those symbols with out speacial meaning.


cheers,
RangaSmilie
# 6  
Old 09-26-2011
Java Tried both the options but did no help...

I tried /usr/bin/perl -i -pe 's/[^\u2103]//g' file.txt > newfile.txt -- It gave an empty newfile.txt and the content of file.txt got changed to the name of it.

sed -e 's/\°//g' -- did not replace the degree symbol either.


PS : The degree symbol is visible only when I select the Show/Hide button on MS Word other wise it doesn't appear. Files with this symbol are not getting processed.

Khedu.
# 7  
Old 09-26-2011
can u try the below

Code:
 
perl -i -pe 's/\xB0//g' file

Code:
 
$ perl test.pl
Before remove : 23°34'N 12°25'W
After remove : 2334'N 1225'W

$ cat test.pl
#!/usr/bin/perl
my $data = "23°34'N 12°25'W";
print "Before remove : $data\n";
$data=~s/\xB0//g;
print "After remove : $data\n";

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove pipe(|) symbol in except the ones which are enclosed in double quotes

I have file with are delimited by pipe(|) symbol, I wanted those to be removed except the ones which are enclosed in double quotes. If your quote file is: |Life is |Beautiful"|"Indeed life |is beautiful too|"|"But unix is fun| is not"|" It should return: Life is Beautiful"|"Indeed life is... (9 Replies)
Discussion started by: Sathyapts
9 Replies

2. Shell Programming and Scripting

Remove/replace the very first character/symbol match

cat file.txt file 1123.x July 23:222 /cd/hh2/k39/ss2/f7d8d9d8e6r5t4s/dd2/e/s7a/s7a2afa5017d8b975-1.7-1395610245-b22e19bbc477b134 i wish to only extract out the 1.7 (anything within the first - -) i try to look for the sed command under match the first occurence of pattern but out of luck, my... (6 Replies)
Discussion started by: ctphua
6 Replies

3. Shell Programming and Scripting

Compare two txt files,mismatches will be in new txt files

Hi, Below are the sample data for txt files. txt file 1 Partnumber|catgroup_id 10001082|46016 10001093|4680 10001093|386003 10001093|463004 10003251|683 10003251|63005 10003252|463005 10003252|4683 10003260|463005 10003260|4683 10003264|4683 10003264|463005 13420000|67... (5 Replies)
Discussion started by: Ankita Talukdar
5 Replies

4. Shell Programming and Scripting

Remove whitespace after pipe symbol but not inside words

I have a file that looks like this: 102| #2 X 1/4-INCH| 30188| EA| FTW| A| NOT SERIAL TRACKING| NOT LOT TRACKING| TRUE| #2 X 1/4-INCH 102| #2 X 1/4-INCH| 30188| EA| VPS| A| NOT SERIAL TRACKING| NOT LOT TRACKING| TRUE| #2 X 1/4-INCH 102| #6 X 1/2"| ... (2 Replies)
Discussion started by: djehresmann
2 Replies

5. Shell Programming and Scripting

remove caret (^) symbol from pattern using sed

Hi, I am trying to remove the caret symbol from a bash variable. This is the variable: var="GOTAN^TOK^B"and this is the code I am trying to use to remove the caret symbol: nocarrot=`echo $var | sed -e 's/^/_/g'`This is the output intended (but not acheived with the above function):... (3 Replies)
Discussion started by: goodbenito
3 Replies

6. Shell Programming and Scripting

how to remove the target of the symbol link in a shell script

I have a target directory, there are some files and directories in "target_dir". I have a symbol link: my_link -> <target_dir> The target directory name is NOT known to the script (because it is varying), while the link name is always fixed. In a shell script, how to remove both the... (1 Reply)
Discussion started by: princelinux
1 Replies

7. UNIX for Dummies Questions & Answers

How to remove characters from multiple .txt files

Friends, I want to remove charecters from multiple .txt files. Foe example : In this .txt files there are many "ctrl m" present in last of each line in one .txt file. I want to remove "ctrl m" from each line from all .txt files. Need your help regarding this. (4 Replies)
Discussion started by: meetsubhas
4 Replies

8. Shell Programming and Scripting

Remove the comment symbol ' from a file.

I want to remove the commented lines in a file identified by ' symbol at the start of each ine. A sample example will be like: Input ----- 'IFerr_flag=0THEN iferr_flag=0then iferr_flag=0then iferr_flag=0then iferr_flag=0then iferr_flag=0then iferr_flag=0then Output -------... (3 Replies)
Discussion started by: joyan321
3 Replies

9. Shell Programming and Scripting

remove verticalbar or pipe symbol

hi guys i have 6000 rows column the text in the column has the symbol vertical bar |. i tried some of the commands to remove it but none of the commands are reconzng this symbol. would u plz help to remove this symbol from the text with any kind of unix command u r help would be appreciated ... (9 Replies)
Discussion started by: bogu0001
9 Replies

10. Shell Programming and Scripting

How to remove certain lines in multiple txt files?

Hi , I have this type of files:- BGH.28OCT2008.00000001.433155.001 BGH.28OCT2008.00000002.1552361.001 BGH.28OCT2008.00000003.1438355.001 BGH.28OCT2008.00000004.1562602.001 Inside them contains the below: 5Discounts 6P150 - Max Total Usage RM150|-221.00 P150 EPP - Talktime RM150... (5 Replies)
Discussion started by: olloong
5 Replies
Login or Register to Ask a Question