1

I have directory with sub-dir where it has multiple extensions file. I would like to copy all ext files to single directory "scan". Tried running following cmd but doesnt work out:

find . -name \*.py -o -name \*.sql -o -name \*.conf -o -name \*.csv -exec cp {} scan/ \;

It just take those specific ext but copy only last ext ie .csv files to "scan" folder

Tried running below command, but it just gives what all ext. files have:

$ find . -type f -name '*.*' | sed 's|.*\.||' | sort -u
conf
coveragerc
css
csv
eot
etlconf
gitignore
hql
html
idx
ini
js
json
log
map
md
pack
pdf
py
sample
sh
sql
svg
ttf
txt
woff
woff2

i would like to run a command that will search all extn files that i have and copy to the scan folder. Thanks!

Inian
  • 12,807
Ankur
  • 11
  • 1
  • 2

1 Answers1

1

A for loop is a less verbose:

$ shopt -s globstar nullglob dotglob
$ for i in **/*.{sql,conf,py,csv}; do 
    cp "$i" "scan/$(basename "$i")"
  done