Shell parses classpackage and copies it to the specified package path

Source: Internet
Author: User
Shell parses classpackage and copies the script to the specified package path, for example, Shell code echo & quot; ############################## class resolution replication tool ##### ################################& quot; echo & quot; # parse all currently. the clas shell parses the class package and copies the script to the specified package path, for example: shell code echo "############################### class parsing and copying tool # #################################### "echo "# # parse all currently. class file and copy it to the corresponding package path. if the file exists, back up the file before copying # "echo" ## usage: # pp. sh Path: class root directory, that is, the class will be copied to the corresponding package with this as the root directory. # "Echo" ################################## hzdev # ######################################## ###### "binPath = $1 if [! -N "$ binPath"]; then echo does not specify the class root directory, exit 0 # binPath = pwd | sed's // g' fi echo ============== class root directory: $ binPath timeStamp = 'Date' + % s' for f in *. class do ################ echo ======== Current class: $ f className = $ (echo "$ f" | sed-e's /\. class // g') className _ = $ (echo $ className | sed's/\ $. * // g') package = $ (javap $ className | grep-oP '(? <= Class ).*(? = \. '$ ClassName _'. * extends) '| sed-e's /\. // g') # echo "className:" $ className # echo "package: "$ package classFile =" $ binPath "/" $ package "/" $ f "classPath =" $ binPath "/" $ package "# echo $ classFile # check path exists if [! -D "$ classPath"]; then echo ==== directory $ classPath does not exist. create the directory mkdir $ classPath-p fi # check class file exists if [! -F "$ classFile"]; then echo "copy files $ f ------------> $ classFile" cp $ f $ classFile else bakFile = "$ classFile ". "$ timeStamp" echo "======> the class file exists and is backed up as $ bakFile" echo "to copy the file $ f ------------> $ classFile" mv $ classFile. $ timeStamp cp $ f $ classFile fi echo "****************************** **************************************** * ******************* "done
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.