rm and mv can also detect the directories just fine, but it you type: rm file
then the shell will ignore the whitespace.
There are a few things you can do to work around this. The easiest is to encapsulate the filename in quotes. Another solution is to escape the special char, e.g. with a backslash
Example:
touch "testfile "
host:/home/username/test>ls -al
total 12
drwx------ 2 hennes users 4096 Sep 26 02:44 .
drwxr-xr-x 34 hennes users 8192 Sep 26 01:39 ..
-rw------- 1 hennes users 0 Sep 26 02:44 testfile
Now to delete them, either:
rm "testfile "
, or
rm testfile\
(please notice the whitespace after the backslash)
As for filenames ending in a dot. I can not reproduce the problem. Are you sure it ends in a dot and not in some other special char?
toad:/home/hennes/test>bash --version
GNU bash, version 4.1.10(1)-release (amd64-portbld-freebsd7.3)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
toad:/home/hennes/test>touch Fun.
toad:/home/hennes/test>ls
Fun.
toad:/home/hennes/test>rm Fun.
toad:/home/hennes/test>ls
toad:/home/hennes/test>
If it is another char than a dot then read up on the Internal file separator in bash. You can set it to something else, or just use commands sunch as find with -print0. (Example find /path/to/search-name 'SomeFilePattern*' -print0 | some_command
)
Best Answer
Files deleted using
rm
are not easily recovered and, although the contents are not overwritten by therm
command the space they occupy is marked as free space and can be used for new files or for additional content added to existing files.As soon as the
rm
command completes, the system is no longer keeping any record of the location of the data for that file.There are file-recovery tools you can use, but that is a separate question. If you don't have a backup - stop using the computer and look for file-recovery tools. Be prepared for total loss though as recovery is not guaranteed.
See