I want to use the MAC address stored in a file in aireplay-ng
command. I want this command to be executed once with each mac address in the file.
Can you please tell me how to do it?
You can try something like xargs -a FILE -d '\n' -L 1 -r COMMAND
. -a
and -d
tell xargs
to read the command line arguments from a file, one argument per line; and -L1 -r
tell it to call the command once per input line, not running it if there's no input.
With pure Bash, you should use a while read
loop:
while IFS= read -r mac; do COMMAND "$mac" ; done < /path/to/file
Here, $mac
will hold each line. The IFS=
is a safeguard for leading and trailing whitespace.
See also: Don't read lines with for
– it's not meant for reading from files.