Cygwin or Gnuwin - Find .txt files named* copy & paste to specific directory

293 views Asked by At

Okay so I want to know how I would go about doing this, using grep to locate .txt files named "cocacola1", "cocacola2", "cocacola3" & then copying them to another directory. So searching for files named "cocacola" &/even if it contains other characters within the file name to then copy them to another directory/location.

1

There are 1 answers

5
Dana On

You can just use unix find. Assuming the files you're searching for are in 'source' and you want to copy to 'destination':

find source -name '*cocacola*' -exec cp {} destination \;

I put the wildcard '*' before and after cocacola since you said other characters might exist in the file name.