The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Remove directory that has special Characters datherriault UNIX for Dummies Questions & Answers 12 01-14-2009 05:53 PM
get rid of special characters vakharia Mahesh UNIX and Linux Applications 4 07-29-2008 01:36 PM
Help replacing or scrubbing unicode characters roninuta Shell Programming and Scripting 3 01-21-2008 11:39 AM
problem with Unicode characters insertion suman_jakkula AIX 0 02-11-2006 01:20 AM
How to display unicode characters / unicode string jackdorso High Level Programming 3 05-20-2005 01:09 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-29-2008
shantanuo shantanuo is offline
Registered User
  
 

Join Date: Aug 2008
Location: Mumbai
Posts: 79
remove special and unicode characters

Hi,
How do I remove the lines where special characters or Unicode characters appear?
The following query does work but I wonder if there is a better way.

cat test.txt | egrep -v '\)|#|,|&|-|\(|\\|\/|\.'

The following lines show that my query is incomplete.

Warning: The word "*Khan" is invalid. The character '*' (U+2A) may not appear at the beginning of a word. Skipping word.
Warning: The word "Khan]" is invalid. The character ']' (U+5D) may not appear at the end of a word. Skipping word.
Warning: The word "Khandewa;l" is invalid. The character ';' (U+3B) may not appear in the middle of a word. Skipping word.
Warning: The word "[khanna" is invalid. The character '[' (U+5B) may not appear at the beginning of a word. Skipping word.
Warning: The word "Khar**Closed" is invalid. The character '*' (U+2A) may not appear in the middle of a word. Skipping word.
Warning: The word "Khelani]" is invalid. The character ']' (U+5D) may not appear at the end of a word. Skipping word.
Warning: The word "Khwaja[physician]" is invalid. The character '[' (U+5B) may not appear in the middle of a word. Skipping w
ord.
Warning: The word "Kids@play" is invalid. The character '@' (U+40) may not appear in the middle of a word. Skipping word.
  #2 (permalink)  
Old 12-05-2008
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,884
To eliminate all but printable characters:
Code:
grep -v '[^[:print]]' test.txt
There's also [:punct:] which are all punctuation characters. Or you can search for anything that doesn't have a normal letter or number:
Code:
grep -v '[^A-Za-z0-9]'
Closed Thread

Bookmarks

Tags
egrep or, special character

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:42 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0