I have a script querying a remote server based on user input and looks for the last modified date of a file. It works, however, contained in the file is a string that I need to have displayed as well and everything I've tried has been for naught. I would really appreciate any help.
Script
echo "Input server name:"
read server
echo "Input user:"
read user
ssh $server "find /home/ -maxdepth 2 -name .lastlogin | xargs -l -I{} bash -c '{
stat -c \"User: %U Last Login : %y\" {} | cut -c -47 |grep $user;
}'"
Current Sample Output
User: owner Last Login : 2014-07-24 15:05:39
I need this output to include the contents of this file, .lastlogin
, which happens to be an IP address.
Desired Sample Output
User: owner Last Login : 2014-07-24 15:05:39 From: 172.0.0.1