![](/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.