LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 12-02-2008, 09:25 PM   #1
JATA01
Member
 
Registered: Nov 2007
Posts: 207

Rep: Reputation: 15
Exclamation ls command!!!


Hi Friends,

I have a question about ls command.

#ls -l
x
y
z

#ls -m
x, y, z

But my question is to print the output like:
x, y and z.

What approach should I be using to get the exact result?

Thanks-
 
Old 12-02-2008, 11:09 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Do you have reason to believe that ls will do that? The man page does not seem to include that option.

I'm guessing that you will have to pipe the output into another command (eg SED).
 
Old 12-03-2008, 04:12 AM   #3
JATA01
Member
 
Registered: Nov 2007
Posts: 207

Original Poster
Rep: Reputation: 15
Now it can be done like this:--

[test@gfmdatabase test]$ y=`ls -m try`;echo "${y%,*} and ${y##*,}"
hello and script1


Thank you!!
 
Old 12-03-2008, 08:05 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
And here is a SED solution:

ls -m|sed 's/ \([^,]*\)$/ and \1/'
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
Turning a Ruby on Rails Ubuntu command into a Redhat command Mangalaiii Red Hat 1 12-02-2008 03:37 PM
Translating windows pscp command to linux scp command help robward Linux - General 2 01-17-2008 06:02 AM
startx command in FC7 reverts me back to the command prompt sriram87 Linux - Newbie 5 01-03-2008 11:18 PM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 02:23 AM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 01:46 AM.

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
Open Source Consulting | Domain Registration