SHELL SCRIPT TO COPY MULTIPLE FILES FROM ASM TO FILESYSTEM

To smartly copy multiple files from ASM to filesystem instead of copying files recursively one by one like a nerd , you may need to save this script in your notepad shelf

This is a one liner

for i in `asmcmd ls FRA/ORCL/FLASHBACK`;do asmcmd cp FRA/ORCL/FLASHBACK/$i /oracle/ ;done

Output: This script takes only 1 minutes and 11 seconds in terms of performance which saves your time in copy of files

[grid@orcl ~]$ time for i in `asmcmd ls FRA/ORCL/FLASHBACK`;do asmcmd cp FRA/ORCL/FLASHBACK/$i /oracle/ ;done
copying +FRA/ORCL/FLASHBACK/log_1.642.1059399021 -> /oracle//log_1.642.1059399021
copying +FRA/ORCL/FLASHBACK/log_10.388.1066593481 -> /oracle//log_10.388.1066593481
copying +FRA/ORCL/FLASHBACK/log_11.633.1072462053 -> /oracle//log_11.633.1072462053
copying +FRA/ORCL/FLASHBACK/log_12.550.1040745057 -> /oracle//log_12.550.1040745057
copying +FRA/ORCL/FLASHBACK/log_13.383.1040745725 -> /oracle//log_13.383.1040745725
copying +FRA/ORCL/FLASHBACK/log_14.324.1040746249 -> /oracle//log_14.324.1040746249
copying +FRA/ORCL/FLASHBACK/log_15.731.1072475109 -> /oracle//log_15.731.1072475109
copying +FRA/ORCL/FLASHBACK/log_16.735.1072634623 -> /oracle//log_16.735.1072634623
copying +FRA/ORCL/FLASHBACK/log_17.588.1072649561 -> /oracle//log_17.588.1072649561
copying +FRA/ORCL/FLASHBACK/log_18.750.1073489419 -> /oracle//log_18.750.1073489419
copying +FRA/ORCL/FLASHBACK/log_19.689.1073512877 -> /oracle//log_19.689.1073512877
copying +FRA/ORCL/FLASHBACK/log_2.755.1065427371 -> /oracle//log_2.755.1065427371
copying +FRA/ORCL/FLASHBACK/log_20.372.1074184217 -> /oracle//log_20.372.1074184217
copying +FRA/ORCL/FLASHBACK/log_21.712.1074204077 -> /oracle//log_21.712.1074204077
copying +FRA/ORCL/FLASHBACK/log_3.729.1065630653 -> /oracle//log_3.729.1065630653
copying +FRA/ORCL/FLASHBACK/log_4.724.1065727519 -> /oracle//log_4.724.1065727519
copying +FRA/ORCL/FLASHBACK/log_5.695.1066336241 -> /oracle//log_5.695.1066336241
copying +FRA/ORCL/FLASHBACK/log_6.690.1066502605 -> /oracle//log_6.690.1066502605
copying +FRA/ORCL/FLASHBACK/log_7.681.1066521233 -> /oracle//log_7.681.1066521233
copying +FRA/ORCL/FLASHBACK/log_8.720.1066577329 -> /oracle//log_8.720.1066577329
copying +FRA/ORCL/FLASHBACK/log_9.627.1066592025 -> /oracle//log_9.627.1066592025

real    1m11.441s
user    0m11.455s
sys     0m1.986s

Another useful script for the same task

asmcmd ls FRA/ORCL/FLASHBACK | while read i; do asmcmd cp FRA/ORCL/FLASHBACK/$i /oracle/ ;done

Output: Compared to previous script this script takes less time than for loop which saves ~ 3 seconds and more efficient in terms of performance

[grid@orcl ~]$ time asmcmd ls FRA/ORCL/FLASHBACK | while read i; do asmcmd cp FRA/ORCL/FLASHBACK/$i /oracle/ ;done
copying +FRA/ORCL/FLASHBACK/log_1.642.1059399021 -> /oracle//log_1.642.1059399021
copying +FRA/ORCL/FLASHBACK/log_10.388.1066593481 -> /oracle//log_10.388.1066593481
copying +FRA/ORCL/FLASHBACK/log_11.633.1072462053 -> /oracle//log_11.633.1072462053
copying +FRA/ORCL/FLASHBACK/log_12.550.1040745057 -> /oracle//log_12.550.1040745057
copying +FRA/ORCL/FLASHBACK/log_13.383.1040745725 -> /oracle//log_13.383.1040745725
copying +FRA/ORCL/FLASHBACK/log_14.324.1040746249 -> /oracle//log_14.324.1040746249
copying +FRA/ORCL/FLASHBACK/log_15.731.1072475109 -> /oracle//log_15.731.1072475109
copying +FRA/ORCL/FLASHBACK/log_16.735.1072634623 -> /oracle//log_16.735.1072634623
copying +FRA/ORCL/FLASHBACK/log_17.588.1072649561 -> /oracle//log_17.588.1072649561
copying +FRA/ORCL/FLASHBACK/log_18.750.1073489419 -> /oracle//log_18.750.1073489419
copying +FRA/ORCL/FLASHBACK/log_19.689.1073512877 -> /oracle//log_19.689.1073512877
copying +FRA/ORCL/FLASHBACK/log_2.755.1065427371 -> /oracle//log_2.755.1065427371
copying +FRA/ORCL/FLASHBACK/log_20.372.1074184217 -> /oracle//log_20.372.1074184217
copying +FRA/ORCL/FLASHBACK/log_21.712.1074204077 -> /oracle//log_21.712.1074204077
copying +FRA/ORCL/FLASHBACK/log_3.729.1065630653 -> /oracle//log_3.729.1065630653
copying +FRA/ORCL/FLASHBACK/log_4.724.1065727519 -> /oracle//log_4.724.1065727519
copying +FRA/ORCL/FLASHBACK/log_5.695.1066336241 -> /oracle//log_5.695.1066336241
copying +FRA/ORCL/FLASHBACK/log_6.690.1066502605 -> /oracle//log_6.690.1066502605
copying +FRA/ORCL/FLASHBACK/log_7.681.1066521233 -> /oracle//log_7.681.1066521233
copying +FRA/ORCL/FLASHBACK/log_8.720.1066577329 -> /oracle//log_8.720.1066577329
copying +FRA/ORCL/FLASHBACK/log_9.627.1066592025 -> /oracle//log_9.627.1066592025

real    1m8.050s
user    0m10.489s
sys     0m1.745s

Hope you enjoyed it!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s