gpt4 book ai didi

linux - 我正在尝试使用 grep 命令

转载 作者:太空宇宙 更新时间:2023-11-04 10:22:14 25 4
gpt4 key购买 nike

我是 Linux 新手,所以这听起来可能很傻。

我正在尝试执行一个命令

sudo arp-scan -l | grep DEVICEMACADDRESS
  1. 此命令的输出保存在哪里。 ? ?
  2. 一旦找到给定的 mac 地址,我如何追加时间。 ? ?

谢谢。

最佳答案

广告 1:默认情况下,Grep 将输出打印到 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)

请注意 = 两边没有空格。另请注意,此变量仅适用于当前终端 session 。但是,您始终可以导出它,或将其保存到文件中。

广告 2:

使用以下语法:

(command_to_find_mac && echo $(date)) >> file

关于linux - 我正在尝试使用 grep 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43387082/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com