Using linuxuglifyjs, I recently learned the linuxshell script and tried to write a batch compression script for uglifyjs. It is not easy to write. please give me more advice. Www.2cto.com environment: ubuntu12.1064bit./bash/node0.8.15/uglifyjs2S .. linux uglifyjs recently learned linux shell scripts and tried to write a batch compression script for uglifyjs. It is not easy to write. please give me more advice. Www.2cto.com environment: ubuntu 12.10 64bit./bash/node 0.8.15/uglifyjs 2 Shell script: 01 #! /Bin/sh02 #03 # This file is used to compress js files.04 # create by Allen Heavey. @ DMDGeeker05 #2013/02/0106 #07 #08 09 function compressJS () {10 uglifyjs $1-c-m-o $111} 12 13 function compress () {14 15 local par = $116 local split = "/" 17 if [-f $ par] & [-r $ par] & ["$ {par ##* .} "=" js "]; then18 compressJS $ par19 elif [-d $ par]; then20 for I in 'ls $ par' 21 do22 local j =$ {par }$ {split }$ {I} 23 # tes T-d $ j & echo "dir $ j" | echo "file $ j" 24 compress $ j25 unset j26 done27 unset i28 fi29 30} 31 32for var in $ @ 33do34 path =$ {var} 35 compress $ path36done usage: save scripts (such as js. sh. sh XXXX (can be a directory or file ). in this way, multiple JS files can be processed in batches at a time to simplify operations.
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