0

First I'm directing to the destination folder by below command

cd /Users/myname/MyFolder/

Now I'm using below command here, what does this command will do?

rm -r ../build ../dist

rm command is for removing, but I'm not able to know how will it work on build and dist directory, and also what does .. mean here?

1 Answer 1

0

The command will (attempt to) remove directories /Users/myname/build and /Users/myname/dist along with all of their contents.

(.. refers to the parent directory)

5
  • /MyFolder has no use here? And I'm getting no such directory found on running above command. What can be the possible reasons? Commented Apr 16, 2020 at 5:38
  • Correct. The .. means "move up one directory", so the commands are not working inside MyFolder. The message no such directory found simply indicates that /Users/myname/build and/or /Users/myname/dist do not exist to begin with, so there is nothing to remove.
    – rtx13
    Commented Apr 16, 2020 at 5:41
  • Is there any way to automate the remove operation, like if the directory is present then remove it, else do nothing? Thanks for the above clarification. Commented Apr 16, 2020 at 5:46
  • Yes you can add the -f force flag to rm. Given this flag, if rm can't find the directory, it will silently ignore it.
    – rtx13
    Commented Apr 16, 2020 at 5:48
  • Warning: rm deletes files and directories without a way to recover them. If you don't understand what it's going to do, then there's a significant chance you'll delete something you didn't mean to. Automating it just increases this risk. You need to start by being clear about what you want to accomplish, and then make sure the commands you use do that, and only that. BTW, how good are your backups? Commented Apr 18, 2020 at 3:54

You must log in to answer this question.

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