![](/img/trans.png)
[英]I am trying to use the grep command in linux. how to grep similar words and phrases
[英]I'm trying to use grep command
我是Linux的新手,所以听起来可能很愚蠢。
我正在尝试执行命令
sudo arp-scan -l | grep DEVICEMACADDRESS
谢谢。
广告1:默认情况下,Grep将输出打印到STDOUT(标准输出),在您的情况下为STDOUT。
如果要将输出保存到文件,请使用输出重定向:
some command > file #this will write file anew (any file will be overwritten)
another command >> file #this will append to file, (file will be created, if doesn't exist)
如果要将输出保存到变量,请使用以下语法:
NAMEOFVARINUPPERCASE=$(whole command)
请注意,=周围没有空格。 另请注意,此变量仅可用于当前终端会话。 但是,您始终可以export
其export
或保存到文件中。
广告2:
使用以下语法:
(command_to_find_mac && echo $(date)) >> file
该命令的输出在哪里保存。 ? ?
回答:您在这里的管道将直接指向STD_OUT,在这种情况下就是您的终端。
如果要保存,请将其重定向到文件。
找到给定的mac地址后如何追加时间。 ? ?
答:只需在重定向到文件时使用它, echo $(date)
。
例如 :
ls | echo $(date)
tor 13 apr 2017 10:30:02 CEST
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.