本文介绍了当在bash中命令时,如果file.txt中有$字符串...做...“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要帮助while命令。如果在playlist.txt中有$ sitename,我想要运行命令



这是我的bash:

  cat playlist.txt | grep -e$ sitename| sed -es /^.* \(http:。*$ sitename。* flv\)。* $ / \1 / g|排序| uniq> checklist.txt 
cat checklist.txt

while [While can find $ sitename in checklist.txt];做
qa
done

这是我已经尝试过的

  while [-n$ echopl]; do 
qa
done

while ['grep -q $ string checklist.txt> / dev / null']; do
qa
done

while [grep -q$ stringchecklist.txt]; do
qa2
done
while grep -q$ stringchecklist.txt;做
qa
done

而grep -q'$ string'checklist.txt; do
qa
done


如果grep -q$ stringchecklist.txt;那么
qa
fi

暂时我把很多if命令:(

ifmorelinks
ifmorelinks
ifmorelinks
ifmorelinks
ifmorelinks

解决方案
 如果grep$ stringchecklist.txt> / dev / null 2& 1;然后
qa
fi


Need help with the while command. I want to run a command if there's a $sitename in playlist.txt

Here's my bash:

   cat playlist.txt | grep -e "$sitename" |  sed -e "s/^.*\(http:.*"$sitename".*flv\).*$/\1/g" | sort | uniq > checklist.txt
cat checklist.txt

while [ " While can find $sitename in checklist.txt" ]; do
                qa
         done

that's what i have tried already

while [ -n "$echopl" ]; do
                    qa
             done

while [ 'grep -q $string checklist.txt >/dev/null' ]; do
                qa
         done

while [  "grep -q "$string" checklist.txt" ]; do
                qa2
         done
while grep -q "$string" checklist.txt; do
    qa
done

while grep -q '$string' checklist.txt; do
    qa
done


if grep -q "$string" checklist.txt ; then
  qa
fi

Temporarily I put many if commands :(

ifmorelinksifmorelinksifmorelinksifmorelinksifmorelinks

解决方案
if grep "$string" checklist.txt >/dev/null 2>&1 ; then
  qa
fi

这篇关于当在bash中命令时,如果file.txt中有$字符串...做...“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 01:06