18

How can I copy all files which starts with "b" or "B" from /bin to a specific folder?

I tried cp /bin* b , but I didn't succeed.

1
  • 1
    cp /bin/b* /to_folder/ should work
    – Simon
    Aug 26, 2013 at 18:22

2 Answers 2

33

Use:

cp /bin/[bB]* ~/tolocation
5
  • 1
    Anyone care to say why the -1?
    – Symin
    Aug 26, 2013 at 18:24
  • Saw the -1 very briefly - it is gone now.
    – gertvdijk
    Aug 26, 2013 at 18:25
  • i'd rather "cp -p" than just "cp" ... Aug 27, 2013 at 9:10
  • I prefer to use cp /bin/[bB]* ~/tolocation/, to ensure that ~/tolocation is a directory and not a file.
    – Zane
    Mar 19, 2014 at 10:21
  • When I did this I got the error No such file or directory. If you also get this error, try the other answer because it worked for me. Feb 3, 2023 at 15:32
14

The right command is:

cp /bin/b* /bin/B* destination

You will probably get this error:

cp: cannot stat ‘/bin/B*’: No such file or directory

That's because there should be no files starting with 'B'. However you shouldn't worry.

You must log in to answer this question.

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