我已经编写了一个脚本来找出当前正在系统上运行的进程以及它们的项目名称。但是在执行脚本之后,得到状态代码= 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'(又名'''命令要求'=')的系统上运行。 –