Operating System - Linux
1756986 Members
3344 Online
108858 Solutions
New Discussion юеВ

non printable characters in all filenames

 
P_F
Regular Advisor

non printable characters in all filenames

I've discovered on recently delivered servers most ( if not all ) files on all filesystems and all LUNS ( local or SAN ) have unprintable characters prepended and appended to the file names.

All new files, post delivery, also contain these unprintable characters.

For example:

^[[00;34mOraInstall2009-03-16_04-20-42PM^[[00m

Note:

# ls -q
# ls -b

Does not reveal the existence these characters.

Note:

The only way to reveal the characters embedded in the filenames is to, for example:

# ls /etc > /tmp/tmp.txt

then

# cat -v /tmp/tmp.txt

or vi the file /tmp/tmp.txt

SIDE EFFECTS:

When using regexp's, or utilities like sed, when these file names are used the utilities will fail, because these characters are - it seems - interfering.

I don't know how this happened?

Any guesses?


4 REPLIES 4
P_F
Regular Advisor

Re: non printable characters in all filenames

I would like to add: the text in the files, is free of any unwanted nuisance characters.
Ivan Ferreira
Honored Contributor

Re: non printable characters in all filenames

Those are just the color string to represent the files.

For example:

# cd /etc
# ls -ld host* > /tmp/files
# cat -e /tmp/files
-rw-r--r-- 1 root root 17 Jul 23 2000 host.conf$
-rw-r--r-- 1 root root 201 Aug 17 2007 hosts$
-rw-r--r-- 1 root root 160 Aug 26 2008 hosts.allow$
-rw-r--r-- 1 root root 346 Aug 26 2008 hosts.deny$

# ls -ld --color=always host* > /tmp/files
# cat -e /tmp/files
^[[00m-rw-r--r-- 1 root root 17 Jul 23 2000 ^[[00mhost.conf^[[00m$
-rw-r--r-- 1 root root 201 Aug 17 2007 ^[[00mhosts^[[00m$
-rw-r--r-- 1 root root 160 Aug 26 2008 ^[[00mhosts.allow^[[00m$
-rw-r--r-- 1 root root 346 Aug 26 2008 ^[[00mhosts.deny^[[00m$


And I don't think that should mess with your regular expressions.

Don't forget to assing points.

Cheers.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
P_F
Regular Advisor

Re: non printable characters in all filenames

solution posted at bottom
Steven Schweda
Honored Contributor

Re: non printable characters in all filenames

> May 12, 2009 21:58:15 GMT 5 pts

You have to wonder what would have gotten
more than half credit.

> [...] files [...] have unprintable
> characters prepended and appended to the
> file names.

More precisely, names is "ls" output have
[...]. The problem is with "ls", not with
the file names themselves.

As usual, it would be helpful if you
described your environment in more detail.
In this case, what your terminal is would be
interesting. Also, what your TERM variable
is. If your stuff is configured properly,
then "ls" should not be sending the color
code strings to a terminal which doesn't
know how to interpret them.

> When using regexp's, or utilities like sed,
> when these file names are used the
> utilities will fail, because these
> characters are - it seems - interfering.

"it seems"? Did you try it? Do you run "ls"
output into sed? Does "ls" add the color
info when its output is not sent to the
user's terminal?