Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

filename is a space? 1

Status
Not open for further replies.

simanek

Programmer
Jan 19, 2001
137
US
Ok, when I do an ls on my directory I get my list of files preceded by one file that is a space. I know it is a space b/c of when I do
prompt>vi_
(the underscore represents a space) I'm not told that it is a new file. question is, how do I delete the file?
rm_(<-space) doesn't work so well). Thanks.

Mike Mike
~~~~
simanek@uiuc.edu
&quot;It's a Swingline!&quot;
~~~~
 
Problem: Somehow a file has been created with a null name in the root partition of a server.
I understand that these files can be created through some bad interaction between PCs running NFS and UNIX systems.

So far I have not been able to remove the null-named file. The technique described in the attached has been recommended from the &quot;UNIX Power Tools&quot; book.

Solution: Move the file to another name based on it's inode number
Here is my example that I had to fix.

1. # ls -lib shows the null-name file as being created as;
\007 (inode 243) and another \007Type\007HE (inode 163).

2 # cd /
# find . -inum 243 -exec mv {} newname1 \;
# find . -inum 163 -exec mv {} newname2 \;
 
that worked! Thanks! Mike
~~~~
simanek@uiuc.edu
&quot;It's a Swingline!&quot;
~~~~
 
If the filename is simply _ (as in a space), you can escape the &quot;space&quot; to avoid the shell interpreting it. So to remove a file call _ (space) all you need to do is

rm \

Note there is a space after the
Greg.
 
I have similar problem

someone creates a file starting with a hyphen &quot;-&quot;, so now I want to change or delete the file, I can not specify that filename because system will look at the - as a start option, eg mv -badfile newfile will display bunch of syntax for options of mv command for me.

How can I change the name of the file?

Also, I have another file name starts with 2 dots &quot;..&quot; !!!

Thanks.
babeo
 
Hello

Same solution give by PNEELY applies to your problem also.

list the files inode by:

#ls -ia (Option (i) will display inode and (a) will display files starting with ..)

then find the file for listed inode and move it with some
valid file name.

# find . -inum (inodenumber)-exec mv {} newname1 \;

Thanx

Sharad
 
you can simple use this:

rm -- -badfile

or

mv -- -badfile newfile

Regards,

Carlos Almeida,
 
If a filename has any characters which are interpreted by the shell, then all you need to do is use a \ to escape those characters when referring to the filename.

Greg.
 
Why not simply try an interactive remove with a wildcard for the space or special characters? Try this rm -i *part_of_file_name*
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top