SHell 涓庤繙鏂?/a>

Posted aswr

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SHell 涓庤繙鏂?/a>相关的知识,希望对你有一定的参考价值。

SHell 涓庤繙鏂?/h1>

鍦?BASH 涓婂仛涓€浜涗笌杩滅鏈哄櫒涔嬮棿鐨勪紶閫掋€傪煢庰煢?/p>

Note

涓囦竴閬囦笂涓€浜涘悕璇嶏紝鎴戞病瑙i噴锛屼綘鍙堝ご鍥炲惉锛屼粠鑰屽鑷翠綘鐪嬩笉鎳傛垜鍦ㄨ鍟ワ紝閭d箞锛屼綘鍙互鑷釜鍎垮厛鏌ユ煡瀹冪殑鎰忔€濓紝鎴栬€呯瓑鎴戠殑銆婄◢鍚庤ˉ鍏呫€嬪鏋滀綘鐩镐俊鎴戜笉浼?鍜曞挄鍜?/em> 鐨勮瘽銆傘€傘€傘€傪煏婐煏婐煏?/p>

0x00

浼楁墍鍛ㄧ煡锛屾湁涓懡浠ゅ彨鈥?code>rsync 銆?/p>

涓嶇煡閬擄紵閭d綘鍙兘鍚繃 scp 锛岄兘涓嶇煡閬撲篃娌′簨锛屾濂姐€?/p>

涓€鑸紝浣犳兂寰€杩滃锛?10.60.111.124 锛夌敤鎸囧畾鐢ㄦ埛锛?heihei 锛夌殑鎸囧畾鐩綍锛?$HOME/yoyo 锛夐噷锛屼紶杩囧幓涓€涓枃浠讹紙 oho.iex 锛夛紝杩欎釜鏂囦欢灏卞湪褰撳墠鐩綍銆?/p>

锛堝鏈満鏉ヨ涔熷氨鏄笂浼犳湰鍦版枃浠跺埌杩滅鏌愮洰褰曪級

閭d箞涓€鑸殑鍋氭硶灏辨槸杩欐牱锛?/p>

rsync -avz -- oho.iex heihei@10.60.111.124:yoyo

杩欐牱鐨勮瘽鑳藉仛鍒颁互涓嬪嚑浠朵簨锛?/p>

  • 瀹屽叏鐩稿悓鐨勬枃浠跺鏋滃凡缁忓湪鐩爣鐩綍瀛樺湪锛岃繖涓枃浠跺氨涓嶄細琚紶杈擄紱鏂囦欢鍚嶇浉鍚屾枃浠跺唴瀹逛笉鍚屽垯浼氳鐩栥€?/li>
  • 閫夐」 a 浣垮緱杩欎釜鏂囦欢鐨勫厓鏁版嵁淇℃伅锛堝垱寤烘椂闂淬€佷慨鏀规椂闂淬€佹枃浠跺綊灞炵瓑杩欎簺骞朵笉瀛樺湪鏂囦欢鍐呭閲岀殑淇℃伅锛夊緱鍒颁繚鐣欙紱閫夐」 z 浼氬紑鍚帇缂╁嵆涓婁紶鍓嶅厛鍘嬬缉杩囦簡缃戠粶鍚庡啀鑷姩瑙e帇锛岃繖鏍峰氨鑳界渷娴侊紱閫夐」 v 鍒欐槸鏄剧ず浼犺緭杩囩▼锛屾湁娌℃湁閮戒笉褰卞搷浼犺緭缁撳眬銆?/li>

鐢变簬瑕佷笂浼犵殑鏂囦欢灏卞湪褰撳墠鐩綍锛屾墍浠?-- 鍚庨潰鐨?oho.iex 杩炵浉瀵硅矾寰勭殑 ./ 涔熶笉鐢ㄥ啓锛屾洿涓嶉渶瑕佸啓缁濆璺緞銆傚張鐢变簬鏂囦欢澶规濂藉湪杩欎釜鐢ㄦ埛鐨?$HOME 鐩綍涓嬶紝鎵€浠ュ啋鍙?: 鍚庨潰涔熶笉鐢ㄥ啓缁濆璺緞銆備簨瀹炰笂锛屽鏋滃彧鏈夊啋鍙?: 鍚庨潰绌虹潃锛屾枃浠跺氨浼氳涓婁紶鍒版墍浣跨敤鐢ㄦ埛 heihei 鐨勫鐩綍銆傦紙浣嗗鏋滀綘鍐掑彿閮芥病鍐欙紝杩欎釜宸ュ叿灏辫涓轰綘鍙槸鎶婃枃浠朵粠鏈湴浼犲埌鏈湴锛屽氨浼氬綋鍓嶇洰褰曞缓绔嬩竴涓?heihei@10.60.111.124 鏂囦欢澶圭劧鍚庢妸鏂囦欢澶嶅埗杩涘幓銆傘€傘€傦級

浠庤繙绔紙 10.60.111.128 锛夐€氳繃鎸囧畾鐢ㄦ埛锛?haha 锛夋妸鎸囧畾鏂囦欢锛?/etc/profile.d/miaomiao.sh 锛夋媺鍒版湰鍦版寚瀹氱洰褰曪紙褰撳墠鐩綍 . 锛夛紝涔熸槸绫讳技鐨勩€?/p>

锛堝鏈満鏉ヨ涔熷氨鏄笅杞芥寚瀹氭枃浠跺埌鏈湴鎸囧畾鐩綍锛?/p>

浣犲彲浠ヨ繖鏍峰啓锛?/p>

rsync -avz -- haha@10.60.111.128:/etc/profile.d/miaomiao.sh .

杩欎釜搴旇涓嶇敤璁茶В浜嗗惂銆傘€傘€?/p>

浣嗘槸锛岃繕鏈変釜闂锛氳繖涓蒋浠堕渶瑕佸闈篃瑁呬簡鎵嶈銆傝€屼笖杩樺緱涓嶈兘鍑洪敊銆?/p>

0x01

濡傛灉鍙叧蹇冩枃浠跺唴瀹圭殑浼犻€掞紝鍙浣犱滑涓よ竟閮芥湁 SSH 锛岄偅涔堝ぇ鍙互鍍忚繖鏍峰仛锛?/p>

鎷夊彇锛堝鏈満鏉ヨ绠椾笅杞斤級

ssh haha@10.60.111.128 -- \'cat /etc/profile.d/miaomiao.sh\' > miaomiao.sh

鎺ㄩ€侊紙瀵规湰鏈烘潵璇寸畻涓婁紶锛?/p>

cat oho.iex | ssh heihei@10.60.111.124 -- \'cat > yoyo/oho.iex\'

褰撶劧锛岃繕鍙互鑷閫夊畾鍘嬬缉宸ュ叿锛堥渶瑕佷袱杈归兘瀹夛級銆傝繖閲屼互 xz 涓句緥锛?/p>

鎷夊彇锛堝鏈満鏉ヨ绠椾笅杞斤級

ssh haha@10.60.111.128 -- \'cat /etc/profile.d/miaomiao.sh | xz -T0 --best\' | xz -dc > miaomiao.sh

鎺ㄩ€侊紙瀵规湰鏈烘潵璇寸畻涓婁紶锛?/p>

(cat oho.iex | xz -T0 --best) | ssh heihei@10.60.111.124 -- \'cat | xz -dc > yoyo/oho.iex\'

鍙﹀锛岀幇鍦ㄤ笉鏄湁寰堝鐜╁鍣ㄥ寲鐨勫悧锛?docker 鐩存帴鎶?Go 杩欎釜璇█甯﹁捣鏉ヤ簡銆傚畠鐨勯暅鍍忔敮鎸佸鍑?save 涓烘枃浠跺拰浠庢枃浠跺拰鍔犺浇 load 銆?/p>

涓€鑸殑鍋氭硶灏辨槸杩滅瀵煎嚭涓€涓枃浠惰捣涓悕瀛楀彨 鍟ュ暐.tar 锛堝鍑虹殑鐨勭‘鏄?Tar 鏍煎紡涓嶇浣犵粰瀹冩枃浠跺悕鍟ユ墿灞曞悕锛夌劧鍚庢尓鍒板彟涓€鍙颁笂鍐嶅鍏ャ€?/p>

鐜板湪鎴戜滑鍙互璁╁畠涓€斿帇缂╋紝骞朵笖鍏ㄧ▼绠¢亾锛屼笉鐢ㄤ笓闂ㄥ厛鐢熸垚鏂囦欢锛屼笉鐣欏浣欑殑涓滆タ銆?/p>

锛堣繖涔熷浜?docker 鍛戒护鏀寔浠庢爣鍑嗚緭鍏ュ姞杞介暅鍍忔垨浠庢爣鍑嗚緭鍑哄啓鍑烘枃浠讹級

锛堣繖閲岀殑鍔虫ā闀滃儚灏辩敤 docker.io/trinodb/trino 浜嗐€傝繖涓伐浣滀富瑕佹槸鐢ㄨ兘杩炰簰鑱旂綉鐨勬満鍣ㄥ線涓嶉€氫簰鑱旂綉鐨勬満鍣ㄤ紶閫侀暅鍍忋€傦級

## 杩滅闀滃儚鏉ユ湰鏈猴細
ssh haha@10.60.111.128 -- \'docker save docker.io/trinodb/trino | xz -T0 --best\' | xz -dc | docker load
## 鏈満闀滃儚鍒拌繙绔細
docker save docker.io/trinodb/trino | xz -T0 --best | ssh haha@10.60.111.128 -- \'xz -dc | docker load\'

## 鐢氳嚦鍙互浠庤繖涓繙绔洿鎺ラ€佸埌閭d釜杩滅锛佸晩瀵癸紒鏅€氭枃浠跺綋鐒朵篃鍙互杩欎箞鐜╁効锛?ssh haha@10.60.111.128 -- \'docker save docker.io/trinodb/trino | xz -T0 --best\' | ssh heihei@10.60.111.124 -- \'xz -dc | docker load\'

0x02

涓嶈繃锛?ssh 鏄瀵嗙爜鐨勶紙鍩轰簬 SSH 鍗忚鐨勫伐鍏烽兘瑕侊紙濡?rsync 灏辨槸涓€涓級锛夈€傝€屾湁鐨勬椂鍊欏叾瀹炰笉渚夸簬杈撳瘑鐮併€傛€庝箞鍔炲憿锛?/p>

鍙互鐢?sshpass 銆?/p>

锛堟煡浜嗕竴涓嬶紝杩欏簲璇ユ槸涓敤 C 鍐欑殑寮€婧愬伐鍏凤紝涓嶈繃璨屼技涔熸湁 PY 鐗堟湰銆傘€傘€傛棤鎵€璋擄紝鍛戒护灏辫兘瀹夛紝杩欓噷涔熸湁鍚勭绯荤粺鐨勫寘銆傦級

鐢ㄦ硶寰堢畝鍗曪細鎶婁笂闈㈢殑 ssh 鎹㈡垚 sshpass -p $xx -- ssh 灏卞ソ浜嗭紝鍏朵腑鍙橀噺 xx 宸茬粡瀛樺叆浜嗗搴旇妭鐐瑰搴旂敤鎴风殑瀵嗙爜銆?/p>

鍑犱釜绀轰緥锛?/p>

## 闀滃儚杩滃埌鏈?sshpass -p $hahapassword -- ssh haha@10.60.111.128 -- \'docker save docker.io/trinodb/trino | xz -T0 --best\' | xz -dc | docker load
## 鏂囦欢杩滃埌杩?sshpass -p $hahapassword -- ssh haha@10.60.111.128 -- \'cat /etc/profile.d/miaomiao.sh | xz -T0 --best\' | sshpass -p $heiheipassword -- ssh heihei@10.60.111.124 -- \'cat | xz -dc > /etc/profile.d/miaomiao.sh\'
## rsync 涔熻兘鐢?sshpass
sshpass -p $heiheipassword -- rsync -avz -- oho.iex heihei@10.60.111.124:yoyo

0x03

浣嗘槸 rsync 杩樿兘涓€涓嬩紶涓€涓枃浠跺す鍛紒

纭疄锛屼笂闈㈣繖绉嶆渶鍘熷鐨勬墜娈靛彧鏄紶鍗曚釜鏂囦欢鑰屽凡銆傝浼犳枃浠跺す鐨勮瘽锛屽ぇ鍙互鍏堟墦鍖呮垚 Tar 鏍煎紡鐨勬枃浠讹紝鐒跺悗鍐嶄紶鍗曚釜鏂囦欢灏卞ソ锛?/p>

锛堢敤 SSH 鍗忚鐨勬椂鍊欏鏋滃垹鎺夋寚瀹氱殑杩滅鐧诲綍鐢ㄦ埛鍚嶅拰 @ 鐨勮瘽灏辩瓑浜庣敤鏈満姝e湪鐢ㄧ殑褰撳墠鐢ㄦ埛鐧诲綍锛岃繖闇€瑕佽繙绔湁鐩稿悓鍚嶇О鐨勭敤鎴峰苟涓斾綘杩樼煡閬撳瘑鐮併€傦級

## 杩滃埌鏈?褰撳墠鐩綍
sshpass -p $xx -- ssh 10.20.202.233 -- \'tar -cf - -- /etc/profile.d\' | tar -x 
## 杩滃埌鏈?鎸囧畾鐩綍涓€旀湁鍘嬬缉
sshpass -p $xx -- ssh 10.20.202.233 -- \'tar -cf - -- /etc/profile.d | xz -T0 --best\' | xz -dc | tar -x -C $HOME/documents
## 鏈埌杩?瀹屽叏鍚屼笂鐨勮鍔?tar -cf - -- /etc/profile.d | xz -T0 --best | sshpass -p $xx -- ssh 10.20.202.233 -- \'xz -dc | tar -x -C $HOME/documents\'
## 杩滃埌杩?瀹屽叏鍚屼笂鐨勮鍔?sshpass -p $xx -- ssh 10.20.202.233 -- \'tar -cf - -- /etc/profile.d | xz -T0 --best\' | sshpass -p $xxx -- ssh 10.20.203.244 -- \'xz -dc | tar -x -C $HOME/documents\'

鍔″繀娉ㄦ剰锛氫笂闈㈢殑渚嬪瓙浼氬湪鐩爣鐩綍涓嬫斁鍏?etc 杩欎釜鐩綍銆傚鏋滃彧鏄兂鎸竴涓洰褰曡€屼笉淇濈暀瀹冨師鏈墍鍦ㄧ粷瀵硅矾寰勭殑淇℃伅锛屽氨璇疯繖鏍凤細

sshpass -p $xx -- ssh 10.20.202.233 -- \'cd /etc && tar -cf - -- profile.d\' | tar -xC . 
(cd /etc && tar -cf - -- profile.d) | sshpass -p $xx -- ssh 10.20.202.233 -- \'tar -x\' 

## -C . 绛変簬涓嶅啓

## 涔嬫墍浠ュ厛 cd 鍒板搴旇矾寰勶紙鍗充究鏄浉瀵硅矾寰勶級鐨?`dirname` 鏄洜涓?## tar 鍦ㄥ帇缂╂椂浼氭牴鎹?-- 鍚庨潰鐨勫€肩洿鎺ュ喅瀹氬瓨鍌ㄥ湪 Tar 鍖呭唴鐨勫悇椤圭殑鍚嶇О
## 锛堣繖涓悕绉板氨鏄寘鍚矾寰勫瓧绗︿覆鍦ㄥ唴鐨勫悕绉板瓧绗︿覆锛?
## 杩欎釜鐗规€т娇寰楀挶浠敤鎴疯兘鐩磋鍦版帶鍒朵粈涔堢▼搴︾殑鐩稿璺緞瀛樺湪鍦ㄤ竴涓?Tar 鍖呭唴鑰屽張涓嶅繀鎶婅繖涓浉瀵硅矾寰勪笅鐨勪竴鍒囬兘鎵撳寘
## 杩欎釜鐗规€т篃灏变娇寰椾笅闈㈢殑鍋氭硶鎴愪负浜嗗彲鑳斤紙褰撶劧涔熻鏇村濂囨€殑鎿嶄綔鎴愪负鍙兘锛?

濡傛灉鎯宠淇濈暀鍘熸潵鐨勭粷瀵硅矾寰勬潵绉诲姩锛屽彲浠ヨ繖鏍凤細

sshpass -p $xx -- ssh 10.20.202.233 -- \'tar -cPf - -- /etc/xxx.d\' | tar -xP 
tar -cPf - -- /etc/xxx.d | sshpass -p $xx -- ssh 10.20.202.233 -- \'tar -xP\' 

## ssh 鐨?-- 鍚庨潰鐨勫懡浠ら噷 鑻ユ病鏈夎濡傜壒娈婂瓧锛?&& || | & ; 锛夌鐨勮瘽 鍗曞紩鍙峰彲浠ヤ笉鍐?## tar 鐨?-P 閫夐」浣垮緱鍦ㄦ搷浣滐紙瀹冨鍘嬬缉鍜岃В鍘嬮兘鑳芥湁鏁堬級鐨勬椂鍊欎笉鍒犻櫎缁濆璺緞鐨勫ご 鍘嬬缉瑙e帇閮藉甫涓婄殑璇濆氨鍙互渚濇嵁瀛樺湪 Tar 鍖呴噷鐨勫師缁濆璺緞淇℃伅鍦ㄦ柊鑺傜偣纭繚鐩爣浣嶇疆杩樻槸鍘熸潵閭d釜

鍏跺疄鍙鑳藉彉鎴?Tar 鍖咃紝鍓╀笅鐨勫氨璺熼暅鍍忕殑杞箟瀹屽叏涓€鏍蜂簡銆?/p>

涓€鑸殑浣跨敤锛?/p>

鎶?ahaha@100.202.103.104 鐨?$HOME 鐩綍涓嬬殑 abc 鐩綍鎸埌鏈満褰撳墠鐩綍 . 涓?/p>

ssh ahaha@100.202.103.104 -- \'tar -cf - -- abc\' | tar -x -C .

鎶婂綋鍓嶇洰褰?. 涓嬬殑 abc 鐩綍鎸埌 ahaha@100.202.103.104 鐨?$HOME 鐩綍涓?/p>

tar -cf - -- abc | ssh ahaha@100.202.103.104 -- \'tar -x -C .\'

0x04

杩樺彲浠ユ壒閲忔悶浜嬫儏銆?/p>

姣斿浣犲湪鏈湴鏌愪釜鐩綍锛屼綘鎯虫妸閲岄潰鎵€鏈夋枃浠跺悕 .docx 缁撳熬鐨勬枃浠朵紶杈撶粰鎸囧畾杩滅鐩綍鐨勭壒瀹氱洰褰曢噷銆?/p>

棣栧厛瑕佹墜鍔ㄥ缓绔嬬洰褰曪細

sshpass -p $xx -- ssh haha@10.20.103.237 -- mkdir -p to_kiki

鐒跺悗杩欐牱灏辫兘浼犱簡锛?/p>

ls *.docx | 
    xargs -i -P0 -- bash -c "cat {} | sshpass -p $xx -- ssh haha@10.20.103.237 -- \'cat > to_kiki/{}\'"

褰撶劧锛屾壒閲忔媺鍙栦篃鏄彲浠ョ殑锛堟潵婧愭枃浠跺す鑲畾宸茬粡鏄湁鐨勬墍浠ヤ笉鍐嶅缓绔嬩簡锛夛細

sshpass -p $xx -- ssh haha@10.20.103.237 -- ls kiki | 
    xargs -i -P0 -- bash -c "sshpass -p $xx -- ssh haha@10.20.103.237 -- \'cat kiki/{}\' > {}"

鎬濊矾灏辨槸鎷兼帴鍛戒护锛屼氦缁?xargs 鎵归噺鎵ц銆?/p>

杩欎簺绀轰緥娌″紑鍘嬬缉锛岄渶瑕佺殑璇濊嚜宸变妇涓€鍙嶄笁銆傚叾瀹炴病蹇呰锛屽彧瑕佷笢瑗夸笉澶ぇ銆?/p>

鍙﹀锛屼篃鍙互涓嶇敤 xz 杩欎釜鍛戒护鏉ュ帇缂╋紝涔熷彲浠ョ敤 zstd 锛屽悗鑰呬技涔庢洿閫傚悎浜庤繖绉嶅満鏅€傦紙鏈潵鐢?.tar.xz 瀛樺畨瑁呭寘鐨?Arch 鍥㈤槦缁忚繃娴嬭瘯鍚庢敼鐢ㄨ繖涓帇缂╃畻娉曪紙绾у埆鏄?18 锛夛紝閫熷害澶у箙鎻愬崌鍚屾椂鍘嬬缉鐜囧垯鍙槸宸簡寰箮鍏跺井涓€鐐圭偣銆?/a>锛?/p>

0x05

杩樺彲浠ヨ繖涔堢潃锛?/p>

sshpass -p $xx -- ssh haha@10.20.103.237 -- \'wget https://ghproxy.com/https://github.com/rustdesk/rustdesk/releases/download/1.1.6/rustdesk-1.1.6.exe -O /dev/stdout\' > rustdesk-1.1.6.exe

濡傛灉浣犳湰鏈轰笉鑳借繛浜掕仈缃戯紝鑰屾煇涓湇鍔″櫒鍙互鐨勮瘽銆?/p>

鍙嶈繃鏉ヤ篃鏄彲浠ョ殑锛?/p>

wget https://ghproxy.com/https://github.com/rustdesk/rustdesk/releases/download/1.1.6/rustdesk-1.1.6.exe -O /dev/stdout | sshpass -p $xx -- ssh haha@10.20.103.237 -- \'cat > rustdesk-1.1.6.exe\'

澶囨敞

鍏跺疄鐭ラ亾鍛戒护璇ユ€庝箞鍒囦細鏇村ソ鐞嗚В銆傜瓟妗堟槸锛屽厛鎸夌収绌烘牸锛堝紩鍙峰鐨勬病杞箟鐨勶級鍒囷紝鍐嶆寜鐓х閬撶 | 鍒囥€?/p>

鍙屾í绾?-- 鍙槸 瀵瑰懡浠や紶鍏ュ弬鏁?(args) 鐨勪竴閮ㄥ垎锛屽彲浠ョ渷鐣ャ€傛敮鎸佷笉鐪佺暐鐨勬椂鍊欏缓璁啓涓婏紝瀹冪殑鍑虹幇涓€鑸剰鍛崇潃锛屽乏杈规槸 閫夐」 (option) 鐨勯儴鍒嗭紝鍙宠竟鏄?鏃犻€夐」鍙傛暟 (para) 鐨勯儴鍒嗐€傚彲浠ユ病鏈夛紝鏈夌殑璇濆垯鑳藉府浣犲涓€涓懡浠よ繘涓€姝ュ垝鍒嗗眰娆°€?/p>

鍝﹀浜嗭紝鍏跺疄瀵逛簬 ssh 鏉ヨ锛岃嫢瑕佺敤 -- 鐨勮瘽锛屾洿瀹屾暣鍦板啓灏变笉鏄?ssh 10.28.101.202 -- hostname -i 鑰屾槸 ssh -- 10.28.101.202 -- hostname -i 浜嗐€備絾锛屽悗鑰呬篃鏄彧鍦ㄥ儚涓嬮潰杩欐牱鐨勬椂鍊欐墠鍏锋湁鍖哄垎灞傛鐨勬剰涔夛細

ssh -o StrictHostKeyChecking=no -- 10.28.101.202 -- hostname -i
## 杩欎釜 -o StrictHostKeyChecking=no 鐢ㄦ潵閬垮厤鍒濇杩炴帴鐨勬椂鍊欓棶浣?yes no 锛岃€屾槸鐩存帴淇′换瀵瑰簲鍦板潃銆?## 涓€鑸槸鍦紝杩滅宸叉槑纭槸鍙俊鐨勶紝骞朵笖闇€瑕佽嚜鍔ㄥ寲鐨勮剼鏈殑鏃跺€欙紝浼氱敤鍒般€?

鍙﹀锛屾洿澶?SHell 鐭ヨ瘑鍙互鐪?a href="https://link.segmentfault.com/?url=https%3A%2F%2Fwww.junmajinlong.com%2Fshell%2Findex%2F" rel="nofollow">杩欎釜銆?/p>


鍒嗕韩娉ㄦ槑鏉ユ簮: https://segmentfault.com/a/1190000040324158

鐣

杩欓儴鍒嗕笉娑夊強鏈枃涓婚锛屼絾鏈変竴瀹氱浉鍏虫€с€?/p>

鐜?Docker 闀滃儚

姝f枃涓彁鍒拌繃 Docker 闀滃儚锛岀敱鎻愬埌杩?Xargs 銆傝繖閲岀粰涓壒閲忓鍑哄鍏ョ殑渚嬪瓙銆?/p>

鎵归噺涓嬭浇

docker search cloudera | fgrep loicmathieu | awk \\{print\\$2\\} | xargs -i -P0 -- bash -c \'fn () { docker pull -- {} >/dev/null && echo ok,${1:-0}: {} || { echo err,${1:-0}: {} ; exec bash -c "$(declare -f fn) ; fn $((${1:-0} + 1))" ; } ; } ; fn\'

涓婇潰鐨?Bash 浼氬悓鏃跺幓涓?docker search cloudera | fgrep loicmathieu 浼氬垪鍑烘潵鐨勬墍鏈夐暅鍍忥紙鏍囩閮芥槸绌虹潃鐨勶級

浼氬嵃鍑烘姤閿欙紝涓嶄細鍗板嚭杩涘害锛屼細鎶ュ憡鎴愬姛杩樻槸澶辫触锛屽鏋滃け璐ヤ細鑷閲嶈瘯銆?/p>

娉ㄦ剰锛氫笂闈唬鐮侀噷鐨?fn 涓嶆槸鍖垮悕鍑芥暟鑰屾槸鍛藉悕鍑芥暟锛屽嚱鏁板悕鍙?fn 锛屽洜涓烘垜鎳掑緱鎯冲悕瀛椻€︹€︿綘涔熷彲浠ユ敼鎴愬埆鐨勶紝涓嶆敼涓嶅奖鍝嶅姛鑳姐€?/p>

鎯宠鐢ㄥ畠鐨勮瘽锛岀湡姝h鏀圭殑涔熷氨鏄墠闈㈢殑 docker search cloudera | fgrep loicmathieu | awk \\{print\\$2\\} 杩欓儴鍒嗭紙浣犲彲浠ョ洿鎺ユ墽琛屼互涓嬬湅鐪嬭繖閮ㄥ垎鐨勬晥鏋滐級锛屽畠鐨勬爣鍑嗚緭鍑哄簲褰撹纭繚鏄竴琛屼竴涓兘鏀惧湪 docker pull 鍚庡ご鐨勫瓧涓茬殑鏍峰瓙銆?/p>

姣斿浣犺繕鍙互鐢ㄨ繖鏍蜂竴鏉″懡浠わ細

docker search ambari | awk /hortonworks/\\{print\\$2\\} | xargs -i -P0 -- bash -c \'fn () { docker pull -- {} >/dev/null && echo ok,${1:-0}: {} || { echo err,${1:-0}: {} ; exec bash -c "$(declare -f fn) ; fn $((${1:-0} + 1))" ; } ; } ; fn\'

涓婇潰鐨勪唬鐮?strong>鍙槸鎴戦『鎵嬪啓鐨勶紝鐞嗚В鍚庢枃涓嶉渶瑕佹悶鎳?/strong>銆傚綋鐒朵綘涔熷彲浠ュ皾璇曞幓鎼炴噦涓€涓嬨€傘€傘€傪煢庰煇婐煢庢€讳箣杩欓儴鍒嗛噸鐐瑰湪涓嬮潰銆?/p>

鎵归噺瀵煎嚭

鍋囪浣犲凡缁忔湁涓€涓枃浠讹細 used-images.imglist

鏂囦欢閲岄噷闈㈡瘡涓€琛屾槸褰㈠杩欐牱鐨勫唴瀹癸細 101.202.103.104/ahahaha/racket:7.9-cs

鍏朵腑锛?/p>

  • 101.202.103.104 鏄畠鏉ヨ嚜鐨?浠撳簱 锛堝嵆鎵€璋?婧?(repo) 锛夌殑鍦板潃锛屽彲浠ユ槸 IP 鍙凤紝鍙互鏄?Hostname 銆?/li>
  • ahahaha 鏄畠鐨?浣滆€?/code> 鍚嶇О锛堟垨璁镐篃浼氭槸椤圭洰鍚嶏級銆?/li>
  • racket 鏄暅鍍忓悕銆?/li>
  • 7.9-cs 鏄爣绛?(Tag) 鍚嶏紝鐢ㄤ簬琛ㄧず姝ら暅鍍忕殑杩唬鐗堟湰銆?/li>

浠g爜绀轰緥

瀵煎嚭鐨勮瘽锛屾渶濂芥湁涓鍑烘枃浠跺す銆傛垜杩欓噷灏卞湪涓婇潰閭f枃浠舵墍鍦ㄧ洰褰曞缓绔嬫柊鐨勬枃浠跺す骞惰繘鍘伙細

mkdir img-saves-d && cd img-saves-d

鐒跺悗鎵ц杩欎釜灏卞ソ浜嗭細

cat ../used-images.imglist |
    xargs -i -P1 -- bash -c \'

echo "pulled: $(docker pull -q -- "{}")" &&
mkdir -p -- "$(dirname "{}")" &&
docker save -- "{}" |
    xz -T0 --best > "{}.tar.xz" &&
echo "save,ok: {}" ;\' ;
杩欓噷鐨勫帇缂╁紩鎿庢病鐢ㄤ簨瀹炰笂鏇翠紭绉€鐨?Zstd 鑰屾槸鐢ㄤ簡 Xz 锛屼富瑕佹槸鍥犱负骞堕潪鎵€鏈夌幆澧冮兘鏈夊畨瑁呭墠鑰咃紝涓斿悗鑰呭湪鍘嬬缉鐜囦笂鏄渶浼樼鐨勶紝涓嶄紭绉€鍙槸鍦ㄩ€熷害銆傚彟澶栵紝涓嶈閫熷害杩樻槸鍘嬬缉鐜囷紝 Zstd 鍩烘湰閮借兘纰惧帇 Gzip 锛堜富瑕佹槸 Gzip 涔熷疄鍦ㄦ槸澶€佷簡鑰?Zstd 鍙堝お鏂颁簡锛夈€?/blockquote>

瀹冩槸杩欎箞鍐欏嚭鏉ョ殑锛?/strong>

  1. 鍏堟槸鍐欎簡涓€涓叿浣撶殑渚嬪瓙锛?/p>

    docker pull -q -- 101.202.103.104/ahahaha/racket:7.9-cs &&
    mkdir -p 101.202.103.104/ahahaha &&
    docker save 101.202.103.104/ahahaha/racket:7.9-cs | xz -T0 --best > 101.202.103.104/ahahaha/racket:7.9-cs.tar.xz
    
  2. 鐒跺悗鎶婄浉鍚岀殑閮ㄥ垎鎶借薄涓€涓嬶細

    docker pull -q -- {} &&
    mkdir -p $(dirname {}) &&
    docker save {} | xz -T0 --best > {}.tar.xz
    

    鍏朵腑闇€瑕佸崟鐙獙璇佷竴涓嬶細

    dirname 101.202.103.104/ahahaha/racket:7.9-cs 
    ## 涓嶈鍟ョ洰褰曢兘鑳借緭鍑?101.202.103.104/ahahaha/racket:7.9-cs 
    ## 鐨勮瘽锛岄偅灏辨病闂銆?
  3. 鐒跺悗缁欐斁鍦?xargs 鍚庨潰锛?/p>

    echo 101.202.103.104/ahahaha/racket:7.9-cs |
        xargs -i -- bash -c \'
    
    docker pull -q -- {} &&
    mkdir -p $(dirname {}) &&
    docker save {} | xz -T0 --best > {}.tar.xz \'
    

    鍙互鎶?bash -c 鎹㈡垚 echo 鐪嬬湅鎵撳嵃鍑烘潵鐨勬槸涓嶆槸鍚堜箮浣犺鎯崇殑鍛戒护锛屽嵆鏄笉鏄悎涔庝笂闈€屽叿浣撶殑渚嬪瓙銆嶃€備笉鍚堜箮灏辫鎯冲姙娉曟敼鍒板悎涔庛€?/p>

    娌¢棶棰橈紝灏辨妸 echo 101.202.103.104/ahahaha/racket:7.9-cs 鎹㈡垚 cat ../used-images.imglist 锛涚洿鎺ュ垎鍒墽琛屼互涓嬭繖涓や釜灏忓懡浠ゅ彲浠ョ湅鍑轰簩鑰呯殑鍖哄埆銆傜劧鍚庢崲浜嗕互鍚庯紝涔熷彲浠ュ厛鎶?bash -c 鎹㈡垚 echo 鎵ц鐪嬬湅锛?/p>

    cat ../used-images.imglist |
        xargs -i -- echo \'
    
    docker pull -q -- {} &&
    mkdir -p $(dirname {}) &&
    docker save {} | xz -T0 --best > {}.tar.xz \'
    
  4. 鍐嶆牴鎹嚜宸辩殑鐗规畩闇€瑕佸鍔犺竟杈硅瑙掑氨鍙互浜嗐€?/p>

    鎴戣繖鏄负浜嗘墦鍗版晥鏋滃仛鎴愪簡涓婇潰閭f牱锛?/p>

    cat ../used-images.imglist |
        xargs -i -P1 -- bash -c \'
    
    echo "pulled: $(docker pull -q -- "{}")" &&
    mkdir -p -- "$(dirname "{}")" &&
    docker save -- "{}" |
        xz -T0 --best > "{}.tar.xz" &&
    echo "save,ok: {}" ;\' ;
    

    杩欓噷 xargs 鐨勫苟鍙戝害閫夐」涔嬫墍浠ユ槸 -P1 锛屾槸鍥犱负锛屽鏋?-P0 鐨勮瘽锛屽氨浼氬彂鐢?鏂紑鐨勭閬?/code> 鐨勬儏鍐碉紙閿欒鎻愮ず杩欎箞鍐欑殑锛夛紝浠庤€屾湁鐨勪笉鑳藉畬鎴愬鍑恒€?/p>

鍝﹀浜嗭紝鏈€濂藉湪瀵煎嚭涔嬪墠灏辨敼濂?repo 鐨勯儴鍒嗭細鏀规垚閫傜敤浜庣洰鏍囧湴鐨?repo 銆?strong>濡傛灉鏄?IP 鍙风殑璇濆彲鑳界‘璁よ捣鏉ヤ細姣旇緝璐瑰姴锛堜笉杩囧簲璇ヤ篃涓嶈垂澶锛?/strong>銆?/p>

鎵归噺瀵煎叆

鍋囪浣犲凡缁忔湁涓€涓枃浠跺す锛?img-saves-d

杩涘叆閲岄潰銆佸苟鎵ц find . -type f 鐨勮瘽锛屽垪鍑虹殑鏄舰濡傝繖鏍风殑涓€琛岃锛?./101.202.103.104/ahahaha/racket:7.9-cs.tar.xz

瀵逛簬閭d釜 find 鍛戒护锛?/p>

  • 閭d釜 . 鏄寚褰撳墠鐩綍銆?/li>
  • 閭d釜 -type 鏄竴涓彨 鏂█ 鑰屼笉鏄?閫夐」 鐨勪笢瑗匡紝涓嶈繃绛夊悓浜庨€夐」鐨勪綔鐢紱鑰?-type f 琛ㄧず鍙細鍒楀嚭銆屾櫘閫氭枃浠躲€嶃€?/p>

    鍏充簬銆屾櫘閫氭枃浠躲€?

    • 鍙互浣跨敤 stat 鏂囦欢鍚?/code> 鏌ョ湅锛堟瘮濡?stat /dev/stdout 锛夛紝鍏朵腑浼氭湁琛ㄧず鏂囦欢绫诲瀷鐨勪綅缃€?/li>
    • 涔熷彲浠ヤ娇鐢?ls -l 鏂囦欢鍚?/code> 鏌ョ湅锛堟瘮濡?ls -l /dev/stdout 锛夛紝鍏朵腑鏅€氭枃浠舵墍鍦ㄨ鐨勭涓€涓瓧绗︽槸 - 銆?/li>

瀵逛簬鍒楀嚭鍐呭锛?/p>

  1. 棣栧厛锛氬垪鍑虹殑鍙槸鍦ㄥ綋鍓嶇洰褰曚笅鐨勬墍鏈夋枃浠剁殑鐩稿璺緞銆?/li>
  2. 鍏舵锛氬彧瑕佹槸鎸夌収涓婇潰鐨勫鍑洪儴鍒嗙殑閫昏緫鍋氱殑瀵煎嚭锛屽緱鍒扮殑瀵煎嚭鍖呮墍鍦ㄧ殑鐩綍缁撴瀯灏变細鏄儚涓婇潰绀轰緥鐨勯偅鏍枫€?/li>
  3. 杩欎釜鐩綍缁撴瀯涓嶆槸寮哄埗鎬х殑銆傚洜涓猴紝姝e父瀵煎嚭鐨勬儏鍐典笅锛屽畬鏁寸殑 婧?/code> 鍜?浣滆€?/code> 鐨勪俊鎭凡缁忓寘鎷湪浜嗚瀵煎嚭鐨勫寘閲屻€?/li>

浠g爜绀轰緥

( onece_load_push () 
{
    be_loadpushed="$1" &&
    errtimes="${2:-0}" &&
    
    push_loaded_cmdmkr ()
    { awk \'/Loaded image:/{split($0,msgarr,"Loaded image: ");print"docker","tag","--","\'"\'"\'"msgarr[2]"\'"\'"\'","\'"\'$be_loadpushed\'"\'","&&","docker","push","--","\'"\'$be_loadpushed\'"\'"}\' | tee -a /dev/stderr ; } &&
    
    xz -dc -- "$be_loadpushed".tar.xz |
        docker load -q |
        push_loaded_cmdmkr |
        
        bash &&
        { echo ok,$errtimes: "$be_loadpushed" >&2 ; } || 
        {
            echo err,$errtimes: "$be_loadpushed" >&2 ;
            exec bash -c "$(declare -f onece_load_push) ; onece_load_push \'$be_loadpushed\' $((errtimes+1))" ;
        } ;
} &&
(find * -name \\*.tar.xz -type f | sed -e s/.tar.xz\\$// -- -) |
    xargs -P0 -i -- bash -c "$(declare -f onece_load_push) ; onece_load_push \'{}\' " )

鎴戠煡閬撶湅璧锋潵寰堝鏉傦紝涓嬮潰浼氳涓€涓嬪畠鏄€庝箞鏉ョ殑鈥︹€?/strong>


鍏堣瘯涓€涓畝鍗曠殑锛?/p>

xz -dc -- ./101.202.103.104/ahahaha/racket:7.9-cs.tar.xz | docker load

鍏朵腑锛岄€夐」閮ㄥ垎鐨?-dc 绛夊悓浜庡啓鎴?-d -c 杩欐牱锛岃€岄噷闈㈢殑閫夐」 -c 绛夊悓浜?--stdout 銆傝繖浜涢兘鍙互鍦?xz --help 鐨勮緭鍑轰腑鏌ュ埌銆?/p>

涓婇潰鑳芥垚鍔熷氨鍙互缁х画锛屼笉鑳斤紝鎰忓懗鐫€瀵煎嚭鐨勫寘鏈夐棶棰樸€傚鍗婂洜涓洪噷闈㈠叾瀹炴槸绌虹殑銆?/p>

閭d箞鍏ㄤ笂搴旇涔熸槸鍙互鐨勶細

濡傛灉杞藉叆鐨勯暅鍍忔病鏀瑰ソ repo 锛屾墍鏈夌殑 push 鍛戒护浣犻兘涓嶄細鎵ц鎴愬姛銆備笉杩囦箣鍚庝細缁欏嚭鍏煎杩欎釜闇€姹傜殑鏂规銆?/strong>

find . -name \\*.tar.xz -type f | xargs -P0 -i -- bash -c \'xz -d --stdout -- "{}" | docker load\'

娉ㄦ剰鍏堟墽琛?cd img-saves-d 銆傝繖涓湪鏈€寮€濮嬫墽琛?find . -type f 鐨勯偅閲屽氨宸茬粡璇磋繃浜嗭紙閭d釜銆岃繘鍏ラ噷闈€嶆寚鐨勫氨鏄繖涓?cd 鍛戒护锛夈€?/p>

鎴愬姛鐨勮瘽锛屼綘搴旇鎬昏兘鐪嬪埌锛屾湁閭d箞涓€琛屽儚杩欐牱鐨勮緭鍑猴細

Loaded image: 101.202.103.104/ahahaha/racket:7.9-cs

骞朵笖鍗充究鏄湪鍚庨潰瀵?docker load 鐢ㄤ笂浜?-q 閫夐」锛屽儚杩欐牱鐨勪竴琛屼粛浼氬嚭鐜板湪鏍囧噯杈撳嚭銆傛垚锛岄偅灏辩敤涓婏細

xz -dc -- ./101.202.103.104/ahahaha/racket:7.9-cs.tar.xz | docker load -q | awk \'/Loaded image:/{split($0,linearr,"Loaded image: ");print linearr[2]}\'

杩欐牱灏卞彧浼氳緭鍑?101.202.103.104/ahahaha/racket:7.9-cs 浜嗭紱閭d箞鎺ヤ笅鏉ョ殑鍛戒护灏卞埄鐢ㄦ鏉ユ嫾锛屾敼鏀逛笂闈㈢殑浠g爜锛?/p>

xz -dc -- ./101.202.103.104/ahahaha/racket:7.9-cs.tar.xz | docker load -q | awk \'/Loaded image:/{split($0,msgarr,"Loaded image: ");print"docker","push","--",msgarr[2]}\'

杩欐牱锛岃緭鍑虹殑灏辨槸鎴戞兂瑕佺殑鍛戒护浜嗐€傚啀琛ヤ笂 | bash 灏辫兘鎵ц瀹冿紝鎴栬€呰繕鍙互鍍忚繖鏍峰琛ヤ笂鐐逛笢瑗匡細

xz -dc -- ./101.202.103.104/ahahaha/racket:7.9-cs.tar.xz | docker load -q | awk \'/Loaded image:/{split($0,msgarr,"Loaded image: ");print"docker","push","--",msgarr[2]}\' | tee -a /dev/stderr | bash

鍏朵腑锛屽琛ヤ笂鐨?| tee -a /dev/stderr 浣垮緱鍛戒护杩樿兘杈撳嚭鍒版爣鍑嗛敊璇竴浠斤紝浠庤€屼笉浼氳繘鍏ョ閬撹€屾槸鎵撳嵃鍑烘潵锛屼粠鑰岃兘鍦ㄦ帶鍒跺彴鐩潃鐨勬椂鍊欏灏戞湁涓暟銆?/p>

濡傛灉闇€瑕佹敼 repo 寤鸿瀵煎嚭涔嬪墠灏辨敼濂斤紝鍚﹀垯杩欓噷灏变笉鑳藉儚杩欐牱锛屽鍏ュ悗鐩存帴 docker push 浜嗐€?/p>

鎺ヤ笅鏉ュ彧闇€瑕佹妸璇ユ浛鎹㈢殑鏇挎崲鎺夛紝鐒跺悗濉叆 xargs 鍛戒护鐨勫弬鏁颁腑姝g‘鐨勪綅缃氨濂姐€?/p>

濡傛灉涓嶉渶瑕佹敼鍚?/h5>

杩欐槸鎴戠殑涓や釜鍐欐垚鐨勪緥瀛愩€?/p>

( push_loaded_cmdmkr () { awk \'/Loaded image:/{split($0,msgarr,"Loaded image: ");print"docker","push","--",msgarr[2]}\' | tee -a /dev/stderr ; } ; find . -name \\*.tar.xz -type f | xargs -P0 -i -- bash -c "$(declare -f push_loaded_cmdmkr) ; xz -dc -- \'{}\' | docker load -q | push_loaded_cmdmkr | bash && echo \'ok:\' \'{}\' || echo \'err:\' \'{}\' " )

涓婇潰杩欎釜鍙互鐩存帴鐢紝濡傛灉 docker push 鐨勯儴鍒嗗け璐ワ紝灏辩洿鎺ユ姤鍑洪敊璇簡銆?/p>

濡傛灉浣犵‘瀹氫綘鐨勯暅鍍忓悕绉版槸娌¢棶棰樼殑锛岃€屼綘鐨?docker push 鍙堟槸浼氱敱浜庣綉缁滃師鍥犲彲鑳戒細涓€斿け璐ョ殑锛岄偅涔堝彲浠ヤ娇鐢ㄤ笅闈㈢殑浠g爜锛?/p>

( onece_load_push () 
{
    be_loadpushed="$1" &&
    errtimes="${2:-0}" &&
    
    push_loaded_cmdmkr ()
    { awk \'/Loaded image:/{split($0,msgarr,"Loaded image: ");print"docker","push","--",msgarr[2]}\' | tee -a /dev/stderr ; } &&
    
    xz -dc -- "$be_loadpushed" |
        docker load -q |
        push_loaded_cmdmkr |
        
        bash &&
        { echo ok,$errtimes: "$be_loadpushed" >&2 ; } || 
        {
            echo err,$errtimes: "$be_loadpushed" >&2 ;
            exec bash -c "$(declare -f onece_load_push) ; onece_load_push \'$be_loadpushed\' $((errtimes+1))" ;
        } ;
} &&
find . -name \\*.tar.xz -type f | xargs -P0 -i -- bash -c "$(declare -f onece_load_push) ; onece_load_push \'{}\' " )

瀹冧細鍦ㄥけ璐ュ彂鐢熸椂鑷姩閲嶈瘯锛岀洿鍒版垚鍔燂紝骞朵笖鍏ㄧ▼浣犲彲浠ユ牴鎹墦鍗扮殑淇℃伅鐪嬪緱鍒板畠澶辫触鐨勬鏁般€傛兂瑕佺畝鐣ョ殑杈撳嚭鍙互鍦ㄥ悗闈㈢殑鎷彿澶栭潰鍔犱笂杩欎釜锛?>/dev/null 銆?/p>

濡傛灉闇€瑕佹敼鍚?/h5>

鍏跺疄鏍规嵁涓婇潰鐨勭畝鍗曚慨琛ュ嵆鍙€?/p>

褰撶劧浜嗭紝杩欓儴鍒嗚姹備綘蹇呴』鏄寜鐓у鍑洪儴鍒嗗舰鎴愮殑鐩綍缁撴瀯鏉ュ瓨鏀?tar.xz 闀滃儚鏂囦欢鐨勩€?/strong>

棣栧厛锛岃鲸鏋愪竴涓嬭繖涓よ€呯殑杈撳嚭鍖哄埆锛?/p>

  • find . -name -type f 锛氳繖涓槸浣滅敤浜庝竴涓洰褰曠殑锛?. 鏄綋鍓嶇洰褰曘€?/li>
  • find * -name -type f 锛氳繖涓槸浣滅敤浜?strong>褰撳墠鐩綍涓?/strong>鐨?strong>鎵€鏈夋枃浠?/strong>鐨勶紝閫氶厤绗?/strong> * 琛ㄧず涓嶈鍙暐鐨勪换浣曟枃浠跺悕锛堢洰褰曞睘浜庝竴绉嶇壒娈婄被鍨嬫枃浠舵晠鐩綍鍚嶆湰璐ㄤ笂涔熷彧鏄?em>鐩綍鏂囦欢鐨勬枃浠跺悕锛?/li>

鐢ㄥ悗鑰咃紝鍐嶅幓鎺夋墿灞曞悗缂€锛屽氨鍙互浣滀负鍚堟硶鐨?Docker 闀滃儚鍚嶄簡銆?/p>

鍘绘帀鍚庣紑鐨勫懡浠ゅ彲浠ョ敤 sed -e s/.tar.xz\\$// -- - 銆傛瘮濡傦細

echo xxx.tar.xz.tar.xz | sed -e s/.tar.xz\\$// -- - # will out: xxx.tar.xz

鐒跺悗锛岃瘯楠屼竴涓嬫敼鍚嶏紝鍏跺疄鏄粰宸插姞杞介暅鍍忓鍔犲埆鍚嶇殑鍔熻兘锛?docker tag

docker tag -- 101.202.103.104/ahahaha/racket:7.9-cs a.b/ahahaha/racket:7.9-cs

鐒跺悗鏌ョ湅闀滃儚灏变細鍙戠幇鏈夋柊澧炵殑鍒悕銆?/p>

鍛戒护 docker tag 鐢ㄦ枃浠剁郴缁熺被姣旂殑璇濓紝灏辨槸涓哄悓涓€涓枃浠跺鍔犱簡 纭摼鎺?/em> 銆?/p>

閭d箞锛屽氨瑕佸湪 Awk 浠g爜閮ㄥ垎锛屽鍔犲舰鎴愭柊鐨勪唬鐮佺殑鍔熻兘銆?/p>

杩欐槸鎴戠殑浠g爜锛?/p>

( onece_load_push () 
{
    be_loadpushed="$1" &&
    errtimes="${2:-0}" &&
    
    push_loaded_cmdmkr ()
    {
        awk \'
        /Loaded image:/ {
            
            split($0, msgarr, "Loaded image: ") ;
            print "docker", "tag", "--", "\'"\'"\'"msgarr[2]"\'"\'"\'", "\'"\'$be_loadpushed\'"\'", "&&", "docker", "push", "--", "\'"\'$be_loadpushed\'"\'" }
        
        \' | tee -a /dev/stderr ;
    } &&
    
    xz -dc -- "$be_loadpushed".tar.xz |
        docker load -q |
        push_loaded_cmdmkr |
        
        bash &&
        { echo ok,$errtimes: "$be_loadpushed" >&2 ; } || 
        {
            echo err,$errtimes: "$be_loadpushed" >&2 ;
            exec bash -c "$(declare -f onece_load_push) ; onece_load_push \'$be_loadpushed\' $((errtimes+1))" ;
        } ;
} &&
(find * -name \\*.tar.xz -type f | sed -e s/.tar.xz\\$// -- -) |
    xargs -P0 -i -- bash -c "$(declare -f onece_load_push) ; onece_load_push \'{}\' " )

鎴?Awk 閭i儴鍒嗕唬鐮佹€庝箞鎷煎嚭鏉ョ殑锛熶竴鐐逛竴鐐规嫾鍑烘潵鐨勩€?/p>

涓嶇啛鎮夌殑鏃跺€欏彲浠ユ瘡鍐欎竴鐐瑰氨鍦ㄥ墠闈㈠姞涓婁釜 echo 101.202.103.104/ahahaha/racket:7.9-cs | 鎵ц鏉ヨ瘯璇曟晥鏋滐紝鐔熶簡灏辫兘鐩存帴鍐欎簡銆?/p>

杩欐牱涓€鏉ワ紝浣犲彲浠ュ埄鐢ㄧ洰褰曠粨鏋勶紝鎶婄洰鏍囬暅鍍忕殑 鍏ㄥ悕 锛堟寚鍖呮嫭 婧?/code> 浣滆€呭悕 闀滃儚鍚?/code> 鏍囩 鐨勫畬鏁寸殑闀滃儚鍚嶏級瀹屽叏鏀规垚浣犳兂瑕佺殑鏍峰瓙锛岀劧鍚庣敤涓婇潰鐨勮剼鏈嵆鍙壒閲忔敼鍚嶅苟涓婁紶锛?push 锛夈€?/p>

姣斿锛屼綘鍙槸鎯虫妸鎵€鏈夌殑 101.202.103.104 婧愭敼涓?101.207.1.1 锛屼綘灏卞彲浠ュ湪褰撳墠鐩綍鎵ц杩欎釜锛?/p>

mv 101.202.103.104 101.207.1.1

鐒跺悗鎵ц鑴氭湰銆?/p>

鏇村鏉傜殑鏀瑰悕闇€瑕佽嚜宸变互姝ょ被鎺ㄣ€?/p>

澶囧繕

锛堣瘽璇村晩锛屾垜涓哄暐杩欎箞寰簭娓愯繘鍐欎笅鎴戝懡浠ゅ舰鎴愮殑姣忎竴鐜妭鍛紵鍥犱负 BASH 涓嶉€傚悎寮€鍙戯紙鎴戞槸璇寸湡鐨勶級锛屽鏋滄湁閿欑殑璇濆緢鍙兘浣犳壘鍒板Д濮ュ鍘讳篃寰堥毦鎵炬槑鐧藉師鍥狅紝鏈夊彲鑳藉緱鎶婄鍧熸寲涓亶锛岀劧鍚庢墠鍙戠幇鍝︽槸杩欓噷鏈夐敊锛岀劧鍚庝綘瀵?Unix 绯荤粺鐨勮璇嗕篃鍔犳繁浜嗭紝鍙笉杩囨洿澶氱殑鍙兘鏄綘鎵句笉鍒般€傘€傘€傛墍浠ワ紝鎴戝缓璁紝鍛戒护瓒婄煭瓒婂ソ锛岃兘鍒お澶嶆潅灏卞埆澶鏉傦紝鎵€鏈夌殑 DSL 鎴戦兘鏄繖涔堝寰呯殑馃槢馃槣馃檭馃檭銆傦級

以上是关于SHell 涓庤繙鏂?/a>的主要内容,如果未能解决你的问题,请参考以下文章

浜鸿劯瀹炴椂姣斿涓庤韩浠借瘉姣斿鍒ゆ柇鏄惁鏄竴涓汉鐨凙ndroid Demo

shell 脚本 片段

代码片段:Shell脚本实现重复执行和多进程

Shell编程入门

PHP鍛藉悕绌洪棿涓庤嚜鍔ㄥ姞杞界被璇﹁В

鍖哄潡閾炬妧鏈湪鏁版嵁涓績搴旂敤鐨勬垚涓庤触

(c)2006-2024 SYSTEM All Rights Reserved IT常识