LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-09-2019, 09:23 PM   #1
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,959

Rep: Reputation: 271Reputation: 271Reputation: 271
'tail -1 *' doesn't work


I just discovered that
Code:
tail -1 *
doesn't work. It returns
Quote:
tail: option used in invalid context -- 1
I have to use
Code:
tail -n 1 *
.
Code:
head -1 *
works. Is there a reason
Code:
tail -1 *
doesn't?
Code:
tail -1 ASpecificFile
works.
 
Old 09-09-2019, 09:41 PM   #2
Mechanikx
Member
 
Registered: Jul 2018
Distribution: Slackware
Posts: 351

Rep: Reputation: 258Reputation: 258Reputation: 258
When using this form

Quote:
tail -1
you're using an obsolete option and you can only give one file as an argument. If you want to pass multiple files you would have to use

Quote:
tail -n 1
https://serverfault.com/questions/13...ard-characters

Last edited by Mechanikx; 09-09-2019 at 09:54 PM. Reason: Added more info.
 
2 members found this post helpful.
Old 09-09-2019, 09:44 PM   #3
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,321
Blog Entries: 28

Rep: Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141
Code:
tail -1 [filename]
tells tail to print the last line of the specified file.

I think that, if you ask tail to print the last line of every file (*), tail just gets confused, because that's not what it's designed to do. It seems to need to be pointed at a specific file.
 
Old 09-09-2019, 11:40 PM   #4
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,959

Original Poster
Rep: Reputation: 271Reputation: 271Reputation: 271
Quote:
Originally Posted by Mechanikx View Post
you're using an obsolete option
OBSOLETE! OBSOLETE! OBSOLETE! http://www.imdb.com/title/tt0734667/?ref_=fn_al_tt_1

The article to which you referred blames tail's use of parse_obsolete_option for this behavior, which no other Unix utility I know has.

Quote:
Originally Posted by frankbell View Post
if you ask tail to print the last line of every file (*), tail just gets confused, because that's not what it's designed to do. It seems to need to be pointed at a specific file.
Why doesn't any other Unix utility get confused? Why doesn't
Code:
tail -n 1 *
confuse it? Mechanikx pointed to the solution, though he has it backwards: parse_obsolete_option.
 
Old 09-10-2019, 02:06 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,836

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
this is how it is implemented. You may try to add your own improvement if you wish.
 
  


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
[SOLVED] head and tail dont seem to work oraenthu@live.com Linux - Newbie 14 03-26-2014 02:53 PM
[SOLVED] /usr/bin/tail -n does not work in solaris 5.9 sreesree Solaris / OpenSolaris 5 11-28-2011 06:30 AM
tail the output of tail -n 1 raj k yadav Linux - Newbie 5 02-06-2010 11:26 PM
How to make newer "tail" behave like older "tail" rylan76 Linux - Software 4 12-07-2007 04:27 AM
root-tail doesn't work!! q6z4k Linux - Software 3 05-14-2006 11:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:26 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