home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 16.12 Useful ls Aliases Chapter 16
Where Did I Put That?
Next: 16.14 Showing Non-Printable Characters in Filenames
 

16.13 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
 
-t -e
 





% 

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 start of the column. Aha... the filename ends with a space. Whitespace characters like TABs have the same problem, though the default ls -q ( 16.14 ) option (on many UNIX versions) shows them as ? if you're using a terminal.

To rename afile , giving it a name without the space, type:

% 

mv "afile " afile

The quotes ( 8.14 ) 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 like rm , too.

- JP


Previous: 16.12 Useful ls Aliases UNIX Power Tools Next: 16.14 Showing Non-Printable Characters in Filenames
16.12 Useful ls Aliases Book Index 16.14 Showing Non-Printable Characters in Filenames

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System