[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Non printable ASCII characters in a file name
From: |
Greg Wooledge |
Subject: |
Re: [Help-bash] Non printable ASCII characters in a file name |
Date: |
Mon, 23 Apr 2012 12:17:45 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Mon, Apr 23, 2012 at 10:06:47AM -0600, Bill Gradwohl wrote:
> Doing an ls on the files in a directory, I came across file names full of
> question marks. Upon further investigation, these are non printable ASCII
> characters.
>
> From the bash command line, how does one key in a non printable character
> so as to be able to uniquely identify a specific file?
>
> Is it possible ?
Dealing with non-printable characters in filename is a pretty broad issue.
The first point is to use "ls -b" to figure out what the actual character
is. Once you know that, then there are a couple avenues available.
Let's assume you simply want to rename the file to something that you
*can* type easily.
If the file has several normal characters in it (or is the only file in
the directory), then you can use a glob:
$ ls
foobar?baz
$ mv foobar*baz foobarbaz
If you want to enter the character explicitly, then you can use bash's
$'...' quoting:
$ ls -b foobar*baz
foobar\002baz
$ mv $'foobar\002baz' foobarbaz
If you want to write scripts that don't blow up in the presence of files
with unusual characters in their names, then brush up on your knowledge
of quoting, and find, and arrays, and so on.