I'm new to linux, especially for ubuntu server and it's terminal.... I have such file structure:


How can i move from second files to main folder, so that t1 contain 1,3.jpg and t2 contain 2,4.jpg...? so that nothing in t1 and t2 to delete, but second subfolder is moved here....

Will be all ok with mv command?

  • Are you sure you have mentioned the correct files in your question? I feel you meant t1 should contain 1, 3.jpg and t2 should contain 2, 4.jpg, right?
    – jobin
    Mar 2 '13 at 16:59
  • Good question, that's how I understood it anyway ;)
    – catalesia
    Mar 2 '13 at 17:02
  • @Jobin sorry, yes you right Mar 2 '13 at 17:03
  • @brabertaser1992: Then, please edit the question to accommodate the correction.
    – jobin
    Mar 2 '13 at 17:05

Yes, you will be OK with mv, eg:

mv /path_to_source_folder/filename /path_to_destination_folder/

or, for example from the level of im/second: (cd im/second)

mv t1/3.jpg ../t1/ && mv t2/4.jpg ../t2/

There are more ways to do that, do man find for example, man rsync

when you look at ls command output, the .. (2 dots) 'means one step back', . (one dot) means 'in here' and you can use it as such

Of course if you want to remove the second folder, you use rmdir command or rm -R (use with care, always do man {command} if you are not sure.

  • Of course if you want to remove the second folder - will mv leave first copy? O_o Mar 2 '13 at 17:12
  • 1
    mv command moves the file, so there will not be any copy, rmdir will not remove the 'second' directory as there are subdirectories. rm -r will or rmdir -p. The best way to learn is to make a copy of the structure and just use the commands and see what happens ;) See what is the difference between rm and rmdir!
    – catalesia
    Mar 2 '13 at 17:16
  • with rm and rmdir i something now.... just where wondered, becouse i didn't understand you Mar 2 '13 at 17:19
  • 2
    command rm -r {path_to_folder} removes the folder and it's subdirectories and files. rmdir removes only folders so it's the best way to remove folders if you wanted to be sure they are empty.
    – catalesia
    Mar 2 '13 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.