I want to run a script that checks if the specific folder exists on a remote server then greps a specific line from a specific file in that server to the local machine.
if ssh -t -t user@server [ -d /etc/nginx ]; then
ssh -t -t user@server
ls -1a /etc/nginx/conf.d | grep $1 | xargs cat | grep specific_line | grep .specific-extension | awk '{print $2}'
fi
I use awk '{print $2}'
to print out the second line of the grepd line
SO I want this to be an output in my local machine or even better I want to put that in a variable in the script.
I haven't find anything on the internet that solves even the simplified version of this.
I have PSK enabled on the servers so I don't have to enter the password when I ssh.