while bash 中的命令“如果 file.txt 中存在 $string...do...”
需要 while 命令的帮助。如果 playlist.txt 中有 $sitename 我想运行一个命令
这是我的 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
这就是我已经尝试过的
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
暂时我放置了很多 if 命令:(
ifmorelinks 如果更多链接 如果更多链接 如果更多链接 如果更多链接
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 :(
ifmorelinks
ifmorelinks
ifmorelinks
ifmorelinks
ifmorelinks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果
$string
的字面意思是$string
而不是string
变量的值,请使用:If
$string
means literally$string
and not the value ofstring
variable, use this: