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?
# 8  
Old 09-26-2011
Quote:
Originally Posted by khedu
...
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.
Try to find out what that degree symbol is - most likely it is not the ascii-character - with hexdump or a similar tool.
# 9  
Old 09-26-2011
Do you have iconv? You can use that to strip out any non-ascii characters.

Assuming your input file is utf8:

Code:
iconv -c -f UTF8 -t ASCII file.txt > file.txt.out

# 10  
Old 09-26-2011
Quote:
Originally Posted by Corona688
Do you have iconv? You can use that to strip out any non-ascii characters.

Assuming your input file is utf8:

Code:
iconv -c -f UTF8 -t ASCII file.txt > file.txt.out


If iconv is not available, given how utf-8 is structured, the following should give an identical result:
Code:
tr -d '\200-\377' <file.txt >file.txt.out


Regards,
Alister
This User Gave Thanks to alister For This Post:
# 11  
Old 09-26-2011
Hi Corona and Alister,

Your command -> iconv -c -f UTF8 -t ASCII source.txt > output.txt.out and tr -d '\200-\377' <file.txt >file.txt.out to remove degree symbol worked fine, I also want to know if we can replace that character with a space as the required space between the two words got removed at the position degree symbol got converted. Thanks a lot for all the help till now on this. Looking forward for your answer on this remaining piece as well. Thanks!

Khedu.
# 12  
Old 09-26-2011
Replacing UTF8 is a lot harder than stripping it out. We don't even know how that character's represented in your data right now...

---------- Post updated at 01:14 PM ---------- Previous update was at 01:11 PM ----------

Hmm... working on alister's solution, here's a way:

Code:
tr -s '\200-\377' ' ' <file.txt >file.txt.out

It should replace any sequence of characters with the 8th bit set(UTF8 sequences), with a single space.
# 13  
Old 09-26-2011
Oh perfect! Works fine..!

Corona Cheers!!

Khedu.
# 14  
Old 09-28-2011
sed -e 's/[\!|\@|\#|\\|\$|\%|\^|\°|\&|\*|\(|\)]//g' se deben escapar los caracteres espaciales anteponiendo "\" .
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