awk/sed 用于测试命令
从我的 ksh 中,
[[ ` echo $READ_LINE | awk '{print $2}' ` != SOME_WORD ]] && print "not match"
我可以获得如何在没有 echo 命令的情况下验证相同内容的建议吗? (也许 awk/sed 适合这个?)
lidia
from my ksh I have
[[ ` echo $READ_LINE | awk '{print $2}' ` != SOME_WORD ]] && print "not match"
can I get suggestion how to verify the same without echo command? ( maybe awk/sed is fine for this? )
lidia
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您使用的是 ksh,那么只需使用 shell 而不必调用外部命令
为什么您仍在解决这个问题,因为我看到您有其他与此类似的线程。
if you are using ksh, then just use the shell without having to call external commands
Why are you still tacking this problem since I see you have other threads similar to this.?
这将按单词分割行并测试第二个单词。
你想要实现什么目标?你的几个问题几乎是相同的。
This splits the line by words and tests the second word.
What is it you're trying to accomplish? Several of your questions are nearly identical.
像这样的东西会起作用:
但是
$READ_LINE
从哪里来?你想实现什么目标?可能还有一个很好的普通sh
或ksh
解决方案。我非常怀疑您的说法:
echo
(可能是 shell 内置函数)比awk
花费更多时间。这是一个plain sh
版本:但是
ksh
丹尼斯·威廉姆森的解决方案看起来最适合您的情况。Something like this will work:
But where does
$READ_LINE
come from? What are you trying to accomplish? There might just also is a good plainsh
orksh
solution.I highly doubt your claim that
echo
(which might be a shell builtin) takes more time thanawk
. Here is aplain sh
version:But the
ksh
solution of Dennis Williamson looks the best for your situation.