Find the answer to your Linux question:
Results 1 to 9 of 9
Hi everyone! I am trying to learn how to open/list down files of a partition in the terminal but I seem to can't get it right. . Like it says ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Engineer nujinini's Avatar
    Join Date
    Apr 2009
    Posts
    1,272

    Terminal Questions?


    Hi everyone!

    I am trying to learn how to open/list down files of a partition in the terminal but I seem to can't get it right.. Like it says "no such file" but ls command says otherwise.

    Here's what I was trying to do. I would really appreciate it if somebody can tell me what am I doing wrong and how I should be doing it instead. Thank you in advance!

    Code:
    [jun@localhost ~]$ su -
    Password: 
    [root@localhost ~]# cd /
    [root@localhost /]# cd media
    [root@localhost media]# ls
    Mint 7  Storage Bin (A)  Storage Bin (B)  Ubuntu 9.10  XP Windows :(
    
    [root@localhost media]# cd Mint 7
    -bash: cd: Mint: No such file or directory
    
    [root@localhost media]# cd Storage Bin (B)
    -bash: syntax error near unexpected token `('
    
    [root@localhost media]# cd Ubuntu 9.10
    -bash: cd: Ubuntu: No such file or directory
    
    [root@localhost media]#
    nujinini
    Linux User #489667

  2. #2
    Linux Guru
    Join Date
    Oct 2007
    Location
    Tucson AZ
    Posts
    3,105
    The problem is spaces and you need quotes, not sure if double or single, I always use double:

    [root@localhost media]# mkdir "Mint 7"
    [root@localhost media]# ls
    cdrom/ dvd/ Mint 7/
    [root@localhost media]# cd "Mint 7"
    [root@localhost Mint 7]#

  3. #3
    Linux Engineer nujinini's Avatar
    Join Date
    Apr 2009
    Posts
    1,272
    Thanks a lot yancek!

    Code:
    [jun@localhost ~]$ su -
    Password: 
    [root@localhost ~]# cd /
    [root@localhost /]# cd media
    [root@localhost media]# ls
    Mint 7  Storage Bin (A)  Storage Bin (B)  Ubuntu 9.10  XP Windows :(
    
    [root@localhost media]# cd "Mint 7"
    [root@localhost Mint 7]# ls
    bin    dev   initrd.img  media  proc  selinux  tmp  vmlinuz
    boot   etc   lib         mnt    root  srv      usr
    cdrom  home  lost+found  opt    sbin  sys      var
    
    [root@localhost Mint 7]# cd media
    [root@localhost media]# cd "Storage Bin (B)"
    [root@localhost Storage Bin (B)]# ls
    [root@localhost Storage Bin (B)]# ls -l
    total 0
    nujinini
    Linux User #489667

  4. #4
    Administrator MikeTbob's Avatar
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    7,864
    You may also use a backslash. Here is an example for you.
    Code:
    ls /media/music/MP3/
    ZZ Top - Beer Drinkers and Hell Raisers.mp3
    ZZ Top - Gimme All Your Lovin'.mp3
    ZZ Top - Just Got Paid.mp3
    ZZTop -Nation Wide.MP3
    Notice the spaces?
    Now use the dir command.
    Code:
    dir /media/music/MP3/
    ZZ\ Top\ -\ Beer\ Drinkers\ and\ Hell\ Raisers.mp3
    ZZ\ Top\ -\ Gimme\ All\ Your\ Lovin'.mp3
    ZZ\ Top\ -\ Just\ Got\ Paid.mp3
    ZZTop\ -Nation\ Wide.MP3
    So then, back to your problem, you could also use:
    Code:
    cd  Mint\ 7 
    cd  Storage\  Bin
    FYI, use the Tab button for autocompletion.
    For example
    Code:
    ls Min (Press Tab button once)
    It should autocomplete the Mint\ 7 for you.
    I do not respond to private messages asking for Linux help, Please keep it on the forums only.
    All new users please read this.** Forum FAQS. ** Adopt an unanswered post.

    I'd rather be lost at the lake than found at home.

  5. #5
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Location
    Boston, MA
    Posts
    4,651
    Just to fill in the blanks a little, no pun intended, the backslash method as Miktbob recommended is called escaping.

    Normally, the shell interprets spaces as a separator between filenames or commands. The escape character tells the shell to interpret the next character literally.

  6. #6
    Administrator MikeTbob's Avatar
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    7,864
    Quote Originally Posted by reed9 View Post
    Just to fill in the blanks a little, no pun intended, the backslash method as Miktbob recommended is called escaping.

    Normally, the shell interprets spaces as a separator between filenames or commands. The escape character tells the shell to interpret the next character literally.
    I knew there was a name for it, but the name escaped me?!
    Thanks reed9.
    I do not respond to private messages asking for Linux help, Please keep it on the forums only.
    All new users please read this.** Forum FAQS. ** Adopt an unanswered post.

    I'd rather be lost at the lake than found at home.

  7. #7
    Linux Engineer nujinini's Avatar
    Join Date
    Apr 2009
    Posts
    1,272
    You may also use a backslash. Here is an example for you.
    Code:
    ls /media/music/MP3/
    ZZ Top - Beer Drinkers and Hell Raisers.mp3
    ZZ Top - Gimme All Your Lovin'.mp3
    ZZ Top - Just Got Paid.mp3
    ZZTop -Nation Wide.MP3
    Notice the spaces?
    Now use the dir command.
    Code:
    dir /media/music/MP3/
    ZZ\ Top\ -\ Beer\ Drinkers\ and\ Hell\ Raisers.mp3
    ZZ\ Top\ -\ Gimme\ All\ Your\ Lovin'.mp3
    ZZ\ Top\ -\ Just\ Got\ Paid.mp3
    ZZTop\ -Nation\ Wide.MP3
    So then, back to your problem, you could also use:
    Code:
    cd  Mint\ 7 
    cd  Storage\  Bin
    Thank you Mike Tbob!

    Code:
    [jun@localhost ~]$ cd /media/Mint\ 7
    [jun@localhost Mint 7]$ cd /media/Storage\ Bin\ (A)
    bash: syntax error near unexpected token `('
    [jun@localhost Mint 7]$ cd /media/Storage\ Bin\ (A)/
    bash: syntax error near unexpected token `('
    [jun@localhost Mint 7]$ cd /media/Storage\ Bin\ (A)\
    bash: syntax error near unexpected token `('
    [jun@localhost Mint 7]$
    How should I end the syntax for cd /media/Storage\ Bin\ (A) please? I tried "/" & "\". No dice

    FYI, use the Tab button for autocompletion.
    For example
    Code:
    ls Min (Press Tab button once)
    It should autocomplete the Mint\ 7 for you.
    This time I tried the Tab button and it completed the syntax. Only If you may notice, I have "Storage Bin (A) & Storage Bin (B)...So I manually completed by putting "B".....but the same question on what character should I end it with as above?

    Code:
    [jun@localhost ~]$ cd /media/Storage\ Bin\ \(B)
    bash: syntax error near unexpected token `)'
    [jun@localhost ~]$
    Last edited by nujinini; 02-23-2010 at 07:18 AM.
    nujinini
    Linux User #489667

  8. #8
    Linux Engineer nujinini's Avatar
    Join Date
    Apr 2009
    Posts
    1,272
    Quote Originally Posted by reed9 View Post
    Just to fill in the blanks a little, no pun intended, the backslash method as Miktbob recommended is called escaping.

    Normally, the shell interprets spaces as a separator between filenames or commands. The escape character tells the shell to interpret the next character literally.
    Thanks reed9.
    nujinini
    Linux User #489667

  9. #9
    Linux Engineer nujinini's Avatar
    Join Date
    Apr 2009
    Posts
    1,272
    I have another partition that I fondly call XP Windows (:

    Just to make sure that those who would use the partition better be careful and scan when downloading.

    Back to my question....the output is different. I noticed that I have to place a "\" before the first character and also after each special character and end with a "/". Then I can get what I want. I hope I got it right

    Code:
    [jun@localhost ~]$ cd /media/XP\ Windows\ \:\(/
    [jun@localhost XP Windows :(]$
    I guess this answers my question Mike Tbob , I hope....

    Thanks!
    nujinini
    Linux User #489667

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •