条件をみたすファイルがなかったら実行
ls | grep xxxx if test $? -eq 1 ;then echo "test" fi
for i in `cat list.txt`; do j=$i"_s.csv" k=`ls | grep -w $j` ls | grep -w $j > tmp if test $? -eq 1; then echo "hello $k"; # abc=2 else echo "hello2 $k"; # abc=3 fi done
おんなじのをrubyで
f=open("list.txt") f.each{|i| i.chomp!(); j=i+"_w.csv" str="ls | grep -w "+j; k=`#{str}` #puts k if k.length ==0 puts j; end } exit();