LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-15-2005, 09:03 AM   #1
basher400
Member
 
Registered: Mar 2005
Posts: 54

Rep: Reputation: 15
simple and easy ls command question


hi all

how do I display the second output item that is produced by the following:

Code:
ls -d burger/2005* | sort -r
lets say the output is something like this:
Code:
burger/2005-01-845
burger/2005-02-464
burger/2005-02-465
burger/2005-03-846
I want to put "burger/2005-02-464" in a var.

thanks
(I just can't find the anwer on google)
 
Old 06-15-2005, 09:26 AM   #2
GlowGlow
Member
 
Registered: Jun 2005
Posts: 111

Rep: Reputation: 15
To see the second item, you can do something like this:

ls | head -n 2 | tail -n 1

(first get the first two, then get the last line of the result), you can put it in a variable by using backticks, e.g.:

BLA=`ls | head -n 2 | tail -n 1`

or the more modern variant:

BLA=$(ls | head -n 2 | tail -n 1)
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
simple cp command question basher400 Linux - Newbie 7 06-08-2005 09:26 AM
A shell command simple question the_rhino Linux - Newbie 6 09-13-2004 02:57 PM
Simple question about mount command Manuel Tejada Linux - General 3 11-02-2002 11:33 PM
Easy question on a command moose1618 Linux - General 5 03-24-2002 12:05 PM
Easy Question on Copy Command aklinuxuser Linux - Newbie 1 08-29-2001 06:55 PM


All times are GMT -5. The time now is 04:37 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration