I'm new to Linux so it may sound silly.
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.
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.
Ad 2:
Use following syntax:
(command_to_find_mac && echo $(date)) >> file