我已經編寫了一個腳本來找出當前正在系統上運行的進程以及它們的項目名稱。但是在執行腳本之後,得到狀態代碼= 0的太多行作爲輸出。可以請任何人幫我解決這個問題對於腳本編程來說是新的。基本腳本
#!/bin/bash
dsjob -lprojects >ProjectName.txt #Fetching the datastage project name running on the server
ps -ef | grep DSD.RUN | cut -d" " -f21 > Currentjoblog.txt #this will contains the current running job on the server
for i in $(< ProjectName.txt);do
dsjob -ljobs $i > $i.txt
for j in $(< $i.txt);do
cat $Currentjoblog.txt | while read LINE
do
if [ x$j == x$LINE ] ;then
echo "$i-------$LINE"
fi
done <"$CurrentJoblog.txt"
done
done
測試字符串'X $ VAR = xstring'是隻在非常老的shell中需要,這很可能不會識別'=='的有效性(它們通常在'test'(又名'''命令要求'=')的系統上運行。 –