LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-04-2007, 07:38 AM   #1
munna_dude
Member
 
Registered: Dec 2006
Posts: 362

Rep: Reputation: 30
tail command help


hi all

i have two directories like this
munna-2.0.1
munna-2.0.2
these two files contains munna.txt
what i am trying to do is(only this is the syntax )
Code:
find /usr/lib/munna* -name munna.txt
the output showing two files...
i need only one..
that is munna-2.0.1

how can i get this ?( i used "tail -1 " but no use )

please help me

thank you in advance
 
Old 10-04-2007, 08:09 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
What criteria do you want to use to decide which file to retrieve? Do you know that it will always be called munna-2.0.1? If so, why not just use that instead of calling find.

The opposite of tail is head, so if you want the first line, you can use that.
 
Old 10-07-2007, 11:18 PM   #3
munna_dude
Member
 
Registered: Dec 2006
Posts: 362

Original Poster
Rep: Reputation: 30
hi all
thank you for kind information..
is there any way to get using tail or head
the perticular line for example 5 th line or 100th line like that


please help me

thank you in advance
 
Old 10-08-2007, 01:40 AM   #4
angrybanana
Member
 
Registered: Oct 2003
Distribution: Archlinux
Posts: 147

Rep: Reputation: 21
Here's an awk way of doing it.
Code:
awk 'NR==4' 'file'        #prints line 4
awk 'NR==2||NR==4' 'file' #prints lines 2 and 4
awk 'NR>=2' 'file         #prints line 2 to the end (tail -n +2 'file')
awk 'NR>=2&&NR<=4' file   #prints lines 2-4

Last edited by angrybanana; 10-08-2007 at 01:44 AM.
 
Old 10-08-2007, 02:30 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
you can use head and tail together eg
cat somefile|head -3|tail -1
gives 3rd line only
cat somefile |head -5|tail -2
gets lines 4 and 5
 
  


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
roo tail, make Error 127, /bin/sh: rman: command not found DraaX Linux - Desktop 4 08-28-2006 09:57 PM
How to see that is the HDD doing EXACTLY like tail johnnydangerous Linux - Software 2 03-17-2005 02:52 PM
Help with 'tail' command! Beppe83 Linux - Software 3 04-07-2004 08:11 AM
Howto end the "tail" command??? Schmurff Linux - Newbie 5 03-03-2004 05:32 AM
tail -f dcoder Programming 8 09-01-2003 08:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:44 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
Open Source Consulting | Domain Registration