スクリプトについて[閉じる]

スクリプトについて[閉じる]

私はこれを理解する必要があります:

df -ah >/opt/pub/software/tmp/Active_directory.txt
find . -type f  -exec ls -l {} \; | sort -nr -k 5  >>/opt/pub/software/tmp/Active_directory.txt&id=$!

#!/bin/bash
#recolecta.sh
date;echo 'Command is running, it will cost about 10 minutes, please wait...'
cd /opt/
df -ah >/opt/pub/software/tmp/Active_directory.txt
find . -type f  -exec ls -l {} \; | sort -nr -k 5  >>/opt/pub/software/tmp/Active_directory.txt&
id=$!
char=("-" "/" "|" "\\") 
n=0 
while ps -ef |grep "$id" |grep -v grep > /dev/null 
do
       echo -ne "\rCommand is running, it will cost about 10 minutes, please wait...${char[$n]} " 
        n=$(( (n+1)%4 )) 
        sleep 1 
done
ls -lht -R >>/opt/pub/software/tmp/Active_directory.txt
tree >>/opt/pub/software/tmp/Active_directory.txt
REMOTE_HOST=$(getOMUName|grep REMOTE_HOST|awk -F '='  '{print $2}')
ssh $REMOTE_HOST

ベストアンサー1

あなたの質問はより具体的でなければなりません。私がよく理解したら、bashスクリプトのとコマンドに問題があるでしょうdffindしたがって、説明は次のようになります。

df -ah >/opt/pub/software/tmp/Active_directory.txt
  • -a偽のファイルシステム、重複ファイルシステム、アクセスできないファイルシステム()を含むファイルシステムのディスク使用量を人が読める形式()として報告し、出力として名前付き-hファイルを作成または上書きします。Active_directory.txt

find . -type f -exec ls -l {} \; | sort -nr -k 5 >>/opt/pub/software/tmp/Active_directory.txt & id=$!

  • 現在のディレクトリで一致するものを見つけてfile type、一致する各ファイル(長いリスト)に対してこれを行い、ls -l出力を5列の数字順に並べ替え、それを逆にします(つまり、より大きなファイルが最初です)。次に出力をファイルに追加します/opt/pub/software/tmp/Active_directory.txt。完全なコマンドはバックグラウンドで実行されます(&)。ジョブのPID($!)はという変数に保存されますid

おすすめ記事