13 Comments Add yours

  1. synthverity says:

    You should just get an error, as ‘mv’ does not have either of those options, du does not have ‘-g’ option, and they are not compatible. If you are on a unix system, learn how to use man pages, as almost all questions can be answered by reading them.

    1. Kim Um says:

      Exactly, this would just give an error in the command line. But it did work one time – I’m not really sure. Let’s say, I have three directories — a, b and c. B directory is inside A, so my current path is /A — while moving /B directory out of /A to /C directory, I kind of entered mv du -sg * in /A directory and all of its files are gone and moved ‘somewhere’. Technically, this shouldn’t work.

      mv: 0653-401 Cannot rename du to users/du:
      A file or directory in the path name does not exist.
      mv: 0653-401 Cannot rename -sg to users/-sg:
      A file or directory in the path name does not exist.

      That’s what I got.

    2. Kim Um says:

      Also, I didn’t enter Ctrl+C while moving. I did the mv du -sg * in a new putty. I didn’t know it would move everything as I thought it wouldn’t work. Technically, it really shouldn’t, right?

      1. synthverity says:

        Assuming that the command ignored the ‘-sg’ portion(which your error seems to imply), ‘mv *’ would move all files in the directory into the final directory listed. If you did this in your home directory, then nothing is really broken. To reverse the process, go into the directory that all the files have been moved into, specify all of the moved files, and use ‘mv (files that you first moved) ..’ Otherwise, ask the administrator to help you.

      2. Kim Um says:

        It did move the files to the final directory and that same final directory was also being moved to another directory. I saw the files at the final dir and started mving it back, but it couldn’t find the files anymore.

  2. du -sg * shows the size of file in current dir in GBs (syntax du -sg (* for all file name; . for current dir size)

    mv is used to move or rename files (syntax mv – Path not required if you are renaming in the same dir.)

    “mv du -sg” would be an incorrect command.

  3. correction in my earlier comment w.r.t mv syntax

    mv (path not required if you are renaming the file in current directory itself.

    1. Kim Um says:

      Thank you for the reply. 🙂 I really appreciate it. Kindly see my reply above to what I got while using mv du -sg *

  4. Kim,
    I am guessing you gave command such as the below (based on your illustration..)

    >$ pwd
    >$ /A
    >$ ls
    >$ B
    >$ mv du-sg * /C

    in the above scenario it will give the error “Cannot rename” error for du and -sg as it cannot find any files named as ‘du’ and ‘-sg’ in /A dir; however the option * would work as expected and move all files from /A to /C (B included).

    (the command will still generate an error code for $? – which should be 1)

    Hope this satisfies the query.

    1. Kim Um says:

      Thank you Ted. Please see my reply above. Things happened really fast and I’m still wondering what really happened. I appreciate the replies.

  5. aaah… I did explain you what happened… Unix is a “Mind my own business” kinda language…. it works with what it finds..

    …and the Name is Venus.

    1. Kim Um says:

      Yeah. I tried the command and I was able to recreate the scenario. Thank youuuu so much for the patience to explain! I really really appreciate it. Gosh, it’s so sad UNIX doesn’t have an “undo” command, lol. And, thanks Venus, and I will assume you are a girl which is soooo cool!! 🙂

  6. You are welcome. And, sorry to disappoint… I am a Guy.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s