Copy files with extension .sh

Hi all...

I am trying to copy all my shell script to some directory using following command, I want to simplify it by not using awk..please some one help me....

find -name "*.sh" | awk -F"/" '{a=$NF;gsub(".sh",x,a);cmd="cp"" " $0" ""/home/akshay/MY_ALL/"a"_"++i".sh";system(cmd)}'

i have not tried this, but you can do something like

for i in `find -name "*.sh"`; do cp $i <destination>; done

Do you want a matching tree, or all in one dir (who wins on name collisions?). Do we need to worry about the command line length? They say any fool can code, but it takes some thought to write requirements. For one dir (last wins):

find * -name '*.sh' -type f | xargs -n101 echo | while read mf
do
cp $mf <destination>
done

Narrative: Find the files one per line, use xargs to echo them out in larger groups (up to 101) on one line, cp each multi-file group to the destination. This has 99+% economy of scale on cp calls but still starts cp long before find is done.

For same subtree:

find * -name '*.sh' -type f | cpio -pd <destination>

If you are copying within the same device (mount), don't want to rewrite them and care about space, you can hard link with 'ln' in place of 'cp'.

Thanks DGPickett

I would like to run script from

 /home/user

reason behind this is I can copy all script to new directory including duplicates., that is why in #1 I used

 ++i

so that it should not overwrite any file