Skip to main content
8 events
when toggle format what by license comment
Nov 10, 2020 at 13:25 comment added terdon @Veverke please post a new question if you need more details and show us the exact commands you used. That said, if you run cp -r foo/* bar one of two things will happen: if bar does not exist, or if it exists but is not a directory, you will get an error message. If it does exist and is a directory, then all non-hidden files/dirs from foo will be copied into bar. If you run cp -r foo/ bar, then if bar exists and is a directory, that will copy the directory foo and place it as a subdirectory of bar. If bar does not exist or is not a directory, you will get an error.
Nov 10, 2020 at 12:58 comment added Veverke @that's why I asked, I always thought the same - my script had /*, but using only / seems to copy the files inside it (and adding it to a cp will create the dir as well). I am a beginner in linux but this is what I see when looking at the results running the command with both syntaxes.
Nov 10, 2020 at 10:43 comment added terdon @Veverke without it, you copy the directory. With it, you copy only what is inside the directory.
Nov 10, 2020 at 9:35 comment added Veverke is adding * after the / is mandatory ? seems to work without it
Jan 25, 2015 at 14:55 comment added terdon @pushandpop well, yes. That's the target you had in your question so I assumed it was a directory. You need to create the target before attempting to copy files into it.
Jan 25, 2015 at 14:52 comment added talkloud You will need to shopt -s dotglob for this to work if there are any dotfiles in /home/username/A/.
Jan 25, 2015 at 14:52 comment added pushandpop Thanks! But it says: /usr/lib/B/ is not a directory
Jan 25, 2015 at 14:48 history answered terdon CC BY-SA 3.0