Pass wildcard array to cp

1

I need help with passing a wild card array to cp, I know it can be done but cant figure it out,

ive got 3 files all start with the word somefile but have 3 different extensions

  • somefile.conf
  • somefile.dat
  • somefile.py

there in a folder with a bunch of other files and I just want to copy them to a different location.

I remember is being something like

cp somefile.[py conf dat] /somewhere

but this isn't working

Ive searched the net and can't find it with the keywords i'm using.

squareborg

Posted 2011-09-12T09:07:42.960

Reputation: 2 105

Answers

2

Depending on the shell, you could use brace expansion

cp somefile.{py,conf,dat} /somewhere

Ignacio Vazquez-Abrams

Posted 2011-09-12T09:07:42.960

Reputation: 100 516

That done the trick thankyou very much, will accept when su lets me – squareborg – 2011-09-12T09:11:53.327