I was making a small script to get the ip address of the $SSH_CLIENT.
#!/bin/bash
set -euf -o pipefail
ip=${SSH_CLIENT%% *}
echo $ip
I keep getting an error with these two methods:
ip=echo $SSH_CLIENT | awk '{ print $1}'
ip=echo $SSH_CONNECTION | awk '{print $1}'
ERROR:
$ ./ignoreip.sh
./ignoreip.sh: line 3: the.ip.address.of.ssh_client: command not found
-> changed the ip address for obvious reasons.
But it works with :
ip=${SSH_CLIENT%% *}
Can anyone explain to me why the two commands do not work but the last one does ?