LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to delete a file who's name starts with a space via CLI (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-delete-a-file-whos-name-starts-with-a-space-via-cli-776684/)

anon091 12-18-2009 09:10 AM

How to delete a file who's name starts with a space via CLI
 
I have a file that when I do a ls -l it shows it as having a space as the first character in its name. how can I do a rm on just that one file? i'm not having any luck due to that space to start the file name.

thorkelljarl 12-18-2009 09:17 AM

What about...

Have you tried the wildcard "?" to replace the blank space?

If so, what else have you tried and what results did you get? Have you tried to quote the file name?

anon091 12-18-2009 09:20 AM

That worked, thanks. is the ? just for a single character wildcard?

paulsm4 12-18-2009 09:28 AM

Hi -

Code:

# EXAMPLE:
% ls -l
-rw-r--r--    1 paulsm  users          0 Dec 18 08:34  has a space
-rw-r--r--    1 paulsm  users          0 Dec 18 08:36 another_file
-rw-r--r--    1 paulsm  users          0 Dec 18 08:36 some_file

# Use a wildcard.
# Be sure to check your wildcard syntax with an "ls"
# before you actually delete anything!
% ls -l ?has*
-rw-r--r--    1 paulsm  users          0 Dec 18 08:34  has a space

# If the wildcard deletes what you want - and ONLY what you want - go for it!
% rm ?has*

'Hope that helps .. PSM

thorkelljarl 12-18-2009 09:29 AM

That was easy...

"?" is for one character. Read and learn more.

http://www.tuxfiles.org/linuxhelp/wildcards.html

anon091 12-18-2009 09:34 AM

Thanks to you both.


All times are GMT -5. The time now is 03:56 AM.