LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-12-2009, 02:22 AM   #1
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 598

Rep: Reputation: 30
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
 
Old 01-12-2009, 03:33 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977
just cd to the directory first, after the echo.
 
Old 01-12-2009, 04:05 AM   #3
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 598

Original Poster
Rep: Reputation: 30
Thanks Chris... Short and Smart way...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Scripting help needed. ZAMO Linux - General 5 12-31-2008 07:36 AM
help needed in scripting ZAMO Linux - General 2 10-31-2008 09:23 AM
Scripting help needed. ZAMO Linux - General 1 09-17-2008 11:35 PM
a little scripting help needed!! vatsan1 Linux - General 6 09-02-2007 09:50 AM
Scripting help needed. stonelee Linux - Software 2 09-29-2003 10:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration