hostname give the output as
server2.mydomain.com
I need to execute 2 commands in the same line
Code:
hostname ; ls -lt /home/zamo|grep -v total |head -1
It gives me an output like this ;
Code:
server2.mydomain.com
drwxrwxr-x 2 zamo zamo 4096 Oct 31 12:40 myscripts
Inorder to bring the output into a single line I modified the command to
Code:
echo -ne `hostname` \\t ; ls -lt /home/zamo |grep -v total|head -1
Again inorder to cut the server2.mydomain.com to server2
Code:
echo -e `hostname` |awk -F\. '{print $1F}' ; ls -lt /home/zamo |grep -v total|head -1
the output is
Code:
server2
drwxrwxr-x 2 zamo zamo 4096 Oct 31 12:40 myscripts
To make the output to a single line, i tried with
Code:
echo -e `hostname` |awk -F\. '{print $1F}' \\t; ls -lt /home/zamo |grep -v total|head -1
echo -e `hostname` |cut -d '.' -f1,1 \\t; ls -lt /home/zamo |grep -v total|head -1
Both failed to get the desired output
I have an issue in using the \\t after awk -F\. '{print $1F}' and |cut -d '.' -f1,1.
Is there any other option to get my output as
Code:
server2 drwxrwxr-x 2 zamo zamo 4096 Oct 31 12:40 myscripts