我有两个文件,如何从两个文件在同一时间阅读shell
A
john 1 2 3 4 5 6 7
Ely 10 9 9 9 9 9 9
Maria 3 5 7 9 2 1 4
Rox 10 10 10 10 10 10 10
B
john 7.5
Ely 4.5
Maria 3,7
Rox 8.5
我想要做的就是创建另一个文件,只有谁在文件中的他们的平均大于或等于与人8.5和B中它们的标记也大于或等于8.5,所以在我的示例中,C文件将仅包含Rox,因为只有她满足标准。
我有这个
#shell program
echo "Fiserul are numele $1"
filename=$1
filename2=$2
echo "">temp.txt
touch results
compara="8.5"
cat $filename | while read -r line
do
nota=0
media=0
echo " $line"
rem=$(echo "$line"| cut -f 2- -d ' ')
for word in $rem
do
echo "$word"
nota=$(($nota+$word))
echo "Nota=$nota"
done
media=$(($nota/7))
if [ "$(echo $media '>=' $compara | bc -l)" -eq 1 ];
then
nume=$(echo "$line"| cut -f 1 -d ' ')
echo "$nume $media" >> temp.txt
fi
echo "Media : $media"
done
cat $filename2 | while read -r line
do
,所以我必须在TEMP.TXT文件谁履行文件中的标准的人,但我的问题是如何通过用文件名2的人比较,并创建“结果“ 从他们 ? 我试过两个while循环,但我得到一个错误,有人可以帮忙吗? 谢谢!
在awk中这样做会容易得多,但我没有时间为你勾画出来。祝你好运。 – shellter 2013-03-26 17:38:59
嘿,谢谢你的提示! – JackRobinson 2013-03-26 17:56:08
@shellter - 史上最差的答案!恭喜! 问:“我怎么骑自行车到芝加哥?” A:“好吧,因为我有一辆非常好的汽车,我会很容易把你开到那里,我也很聪明,但是抱歉,我没有时间,祝你好运!” – user3133172 2015-08-12 08:08:34