Results 1 to 4 of 4

Thread: Moving Files / Folders in Terminal

  1. #1
    Join Date
    Sep 2013
    Beans
    8

    Moving Files / Folders in Terminal

    Yeah I am a beginner lol. Just a quick question.

    I have read up on all the ways to move files and directories in the Terminal but for some odd reason nothing is ever working for me. Here is the current situations I am running into.

    I created a folder called GPU Test onto my Desktop. Problem is when I try to cd /user/me/Desktop/GPU Test
    it will say that there is no such directory.

    Same is happening when I try to move files. Say I created a file inside the Documents folder and want it moved to the GPU Test folder.

    if I try

    mv user/me/Documents/documentname


    then what? Do I just use a space between documentname and the folder I want to send it to? All the examples so far have been ... for some reason using ............. type syntax all over the actual code line so its impossible to read what they actually mean.

    would the end line read:
    mv user/me/Documents/documentname user/me/Desktop/GPU Test
    ?

    Or is there something I have to put between the 2 directories?

    Then of course I have to figure out why I simply can't even go into the GPU Test folder on my desktop from the Terminal. That one is really confusing me.
    Last edited by aaron-huddleston30; September 26th, 2013 at 02:51 AM.

  2. #2
    Join Date
    Sep 2008
    Location
    Chicago
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Moving Files / Folders in Terminal

    If only all problems were so simple! The issue is that unadorned cd parses your command as if you had written
    Code:
    cd /user/me/Desktop/GPU
    In other words, it sees the space as a separator and naturally can't find the nonexistent directory (GPU). You need to do this
    Code:
    cd '/user/me/Desktop/GPU Test'
    Try it with single (or double) quotes and let me know the result.
    Last edited by whitesmith; September 26th, 2013 at 04:09 AM. Reason: clarity
    In working with *nix...There be dragons. Newcomers: I recommend reading Linux is Not Windows (http://linux.oneandoneis2.org/LNW.htm) and The Linux Command Line (http://www.linuxcommand.org/tlcl.php) before beginning your quest for a better OS.

  3. #3
    Join Date
    Aug 2011
    Location
    52° N 6° E
    Beans
    2,869
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Moving Files / Folders in Terminal

    All those command like cd, mv, cp, rm etc. use space as a separator. In fact, it's a property of the shell, not of the commands themselves. To use files or directories with space in their names you either quote the name ("like this" or 'like this', there's a slight difference between them) or you escape\ all\ spaces\ with\ backslashes.

  4. #4
    Join Date
    Jul 2007
    Location
    Magic City of the Plains
    Beans
    Hidden!
    Distro
    Xubuntu 15.04 Vivid Vervet

    Re: Moving Files / Folders in Terminal

    Code:
    mv user/me/Documents/documentname user/me/Desktop/GPU Test
    For this to work you'd need a couple small changes. As mentioned, use \ to escape the space in GPU Test. If you use tab completion the shell will do this for you.

    When moving a file to a certain folder, always use a trailing /. Here's what I mean:
    Code:
    mv user/me/Documents/documentname user/me/Desktop/GPU\ Test/
    Reason being that mv can also function as a rename command, so in your original command above the shell would move documentname to the Desktop folder and rename it to GPU Test. The trailing / tells the shell to move the file to the existing folder GPU Test and nothing more. Hope that's clear.

    There's a free PDF here, it's a good tutorial on learning the command line and I think you would benefit by taking a look at it. I've been using Linux for six years and I still refer to it quite a bit myself.

Bookmarks

Posting Permissions

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