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 > Special Forums > UNIX and Linux Applications
.
google unix.com



UNIX and Linux Applications Discuss UNIX and Linux software applications. This includes SQL, Databases, Middleware, MOM, SOA, EDA, CEP, BI, BPM and similar topics.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
grep with special characters guruparan18 UNIX Desktop for Dummies Questions & Answers 3 06-12-2008 05:58 AM
How to find special characters?? sumitc AIX 3 05-04-2008 08:20 PM
Handling special characters using awk sam_78_nyc Shell Programming and Scripting 3 11-08-2007 05:55 PM
special characters nawnaw UNIX for Dummies Questions & Answers 2 05-18-2004 03:17 PM
awk/sed with special characters apalex Shell Programming and Scripting 5 05-06-2002 04:40 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 07-28-2008
vakharia Mahesh vakharia Mahesh is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 51
get rid of special characters

Hi Friends,

we have recently installed RHEL4.4 and when i give the commd
ls -l > tt it prints the file name with some special charactes like
^[[00m1 in the begining of the file name and at the end of the file name. I wanted to use the file names of removing it before taking
the backup and to use in awk script I want to remove the unprintable
characters .
I have tried
sed 's/^[...../p' input file > output file , but the characters varies in their
lenght so unable to remove . kindly guide ..

Thanks in advance for help.
  #2 (permalink)  
Old 07-28-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Question Can you provide a sample?

Sample input - what you are seeing
Sample output - your desired end-result
help in solving many problems.

That is especially true here since one prefix does not allow for the undertanding of a pattern.
  #3 (permalink)  
Old 07-28-2008
quine quine is offline
Registered User
  
 

Join Date: Mar 2008
Location: Bay Area California
Posts: 68
It's real DATA ANALYSIS!

Why are you using "ls -l" if all you want is the names? Try ls -1.. That will simplify things for you... As for the special characters, get used to "od" Octal Dump.... Look at the hex values... try

ls -1 | od -cx > somefile

Then you can actually see what values are in those "unprintable" columns. Impossible to tell from what you write here because every character set interprets those values differently.... Once you know what the characters really are (in hex) you can come up with a way of eliminating them... Still, I don't know what RHEL is... Is it real unix?
  #4 (permalink)  
Old 07-29-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
RHEL is Red Hat Enterprise (mumble) something, i.e. Linux.

Maybe it's as simple as "unalias ls". Some distros provide an alias which enables directory coloring, which will output some escape codes to provide text in different colors. If your terminal doesn't understand those escape codes, you would see something like what you describe.
  #5 (permalink)  
Old 07-29-2008
quine quine is offline
Registered User
  
 

Join Date: Mar 2008
Location: Bay Area California
Posts: 68
Escape codes... Colors...

Yes makes sense. Hadn't thought of that. I've got a little project of my own that requires getting rid of escapes like that (simple perl pattern). I wondered what they might be for, now I remember... thanks

$INPTBffr =~ s/[^\x0A\x0D\x20-\x7E]+//g;

Using something like the above to strip binaries, and newlines leaving pure text stream.....
Closed Thread

Bookmarks

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 09:17 AM.


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