Can't Access a File? Look for Spaces in the Name (Unix Power Tools, 3rd Edition)
8.11. Can't Access a File? Look for Spaces in the Name
What's wrong here?
% ls
afile exefiles j toobig
% lpr afile
lpr: afile: No such file or directory
Huh? ls shows that the file is there,
doesn't it? Try using:
-v Section
12.4, -t -e Section 1125
% ls -l | cat -v -t -e
total 89$
-rw-rw-rw- 1 jerry 28 Mar 7 19:46 afile $
-rw-r--r-- 1 root 25179 Mar 4 20:34 exefiles$
-rw-rw-rw- 1 jerry 794 Mar 7 14:23 j$
-rw-r--r-- 1 root 100 Mar 5 18:24 toobig$
The cat -e option marks the ends of lines with
a $. Notice that afile has a
$ out past the end of the column. Aha . . . the
filename ends with a space. Whitespace characters like
TABs have the same problem, though the
default ls -q (Section 8.12) option (on many Unix versions) shows them as
? if you're using a terminal.
If you have the
GNU version of ls, try
its -Q option to put double quotes around each name:
$ ls -Q
"afile " "exefiles" "j" "toobig"
To
rename afile, giving it a name without the
space, type:
% mv "afile " afile
The quotes (Section 27.12) tell the shell to include the space as part
of the first argument it passes to mv. The same
quoting works for other Unix commands as well, such as
rm.
-- JP
8.10. Useful ls Aliases8.12. Showing Nonprintable Characters in Filenames
Copyright © 2003 O'Reilly & Associates. All rights reserved.
Wyszukiwarka
Podobne podstrony:
ch08ch08ch08ch08ch08ch08ch08CH08ch08ch08 (17)ch08ch08ch08ch08ch08ch08CH08więcej podobnych podstron