Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

From the following results it appears the *.rar is being taken literally, and not expanded. man glob gives no detail as to how it expands. Would someone kindly explain why?

~/Films $ls "Night of the Living Dead (1968)/"  
Night_of_the_Living_Dead_1968.par2        Night_of_the_Living_Dead_1968.part23.rar.1  
Night_of_the_Living_Dead_1968.part01.rar  Night_of_the_Living_Dead_1968.part24.rar  
...

~/Films $ls "Night of the Living Dead (1968)/*.rar"  
ls: cannot access Night of the Living Dead (1968)/*.rar: No such file or directory  
~/Films $ls "$(pwd)/Night of the Living Dead (1968)/*.rar"  
ls: cannot access /home/g/Films/Night of the Living Dead (1968)/*.rar: No such file or directory  
~/Films $ls "Night of the Living Dead (1968)/*rar"  
ls: cannot access Night of the Living Dead (1968)/*rar: No such file or directory  
share|improve this question

migrated from stackoverflow.com Nov 11 '11 at 2:42

This question came from our site for professional and enthusiast programmers.

    
do ls "Night of the Living Dead (1968)"/*rar – nos Nov 10 '11 at 12:43

A * inside single quotes is treated literally. So you need to put only the directory name that has spaces in it, in quotes:

ls "Night of the Living Dead (1968)"/*.rar  

A * inside double quotes is expanded by the shell.

share|improve this answer
1  
A * inside single quotes is treated literally. A * inside double quotes is expanded as a glob. – William Pursell Nov 10 '11 at 14:19
    
apologies--I was thinking the OPs issue was that ls was set to a function or an alias that was munging the quotes; but in fact it is my function that was causing "*" to expand! I cannot remove the downvote unless you edit your answer. – William Pursell Nov 10 '11 at 14:30
    
An easier way to do this interactively is ls Night[TAB]/*.rar; let the shell complete the directory name rather than typing it out. The shell's tab completion will insert backslashes as necessary to escape any special characters. – Keith Thompson Mar 13 '12 at 19:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .