LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Scripting help needed. (https://www.linuxquestions.org/questions/linux-general-1/scripting-help-needed-696653/)

ZAMO 01-12-2009 01:22 AM

Scripting help needed.
 
Hi all,


I have a question on scripting . I used to list some files in my remote server along with the hostname and it is working fine .

Code:

ssh sever2 'echo -ne $HOSTNAME \\t  ;ls -lt /home/zamo/testing`
It is working fine. It gives the output as

Code:

server2 -rw-r--r--  1 zamo  zamo      25 jan 11 19:01 /home/zamo/tesing

I want the file name only , not with the absolute path. Normally I do

awk -F\/ '{print $NF}' to cut that and it is not working on remote.

I need to get the output as follows.
Code:

server2 -rw-r--r--  1 zamo  zamo    25 jan 11 19:01 tesing

Thanks

acid_kewpie 01-12-2009 02:33 AM

just cd to the directory first, after the echo.

ZAMO 01-12-2009 03:05 AM

Thanks Chris... Short and Smart way...


All times are GMT -5. The time now is 11:06 PM.