[英]I'm trying to use grep command
I'm new to Linux so it may sound silly. 我是Linux的新手,所以听起来可能很愚蠢。
I'm trying to execute a command 我正在尝试执行命令
sudo arp-scan -l | grep DEVICEMACADDRESS
Thank you. 谢谢。
Ad 1: Grep by default prints output to STDOUT (standart output), which is, in your case, terminal. 广告1:默认情况下,Grep将输出打印到STDOUT(标准输出),在您的情况下为STDOUT。
If you want to save the output to the file, use output redirection: 如果要将输出保存到文件,请使用输出重定向:
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)
If you want to save the output to variable, use following syntax: 如果要将输出保存到变量,请使用以下语法:
NAMEOFVARINUPPERCASE=$(whole command)
Please note there are NO spaces around =. 请注意,=周围没有空格。 Also note, that this variable is available only to current terminal session.
另请注意,此变量仅可用于当前终端会话。 However, you can always
export
it, or save it to file. 但是,您始终可以
export
其export
或保存到文件中。
Ad 2: 广告2:
Use following syntax: 使用以下语法:
(command_to_find_mac && echo $(date)) >> file
where does the output of this command gets saved.
该命令的输出在哪里保存。 ?
? ?
?
Ans: Your just piping here this will direct to STD_OUT that is your terminal in this case. 回答:您在这里的管道将直接指向STD_OUT,在这种情况下就是您的终端。
If you want to save redirect this to file. 如果要保存,请将其重定向到文件。
How I can append time once the given mac address is found.
找到给定的mac地址后如何追加时间。 ?
? ?
?
Ans: just use this while redirecting to file, echo $(date)
. 答:只需在重定向到文件时使用它,
echo $(date)
。
for example : 例如 :
ls | echo $(date)
tor 13 apr 2017 10:30:02 CEST
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.