LinuxQuestions.org
Review your favorite Linux distribution.
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 05-04-2018, 01:29 PM   #1
zaper
LQ Newbie
 
Registered: Sep 2017
Posts: 22

Rep: Reputation: Disabled
what is the point of '"tac" ?


i was bored so i decided to browse some man pages, in cat's man page there was a reference to a command called "tac", hmm interesting i decided to investigate turns out it is literally just cat but where line number 10 would be line number 1 line 2 would be 8 etc so i just wanted to ask why does it exist ? what's it's point ?
 
Old 05-04-2018, 01:49 PM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Did you look at man tac?
Code:
tac - concatenate and print files in reverse
 
Old 05-04-2018, 01:51 PM   #3
zaper
LQ Newbie
 
Registered: Sep 2017
Posts: 22

Original Poster
Rep: Reputation: Disabled
yes i can also read a man page i meant why would you ever use it ? why is it there ?

Last edited by zaper; 05-04-2018 at 02:11 PM.
 
Old 05-04-2018, 02:07 PM   #4
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
tac is a very old command. Sometimes users wanted to view a file in reverse. Like for example a log file and view it in reverse.
Code:
tac mylogfile | more
Remember that in those days users might have used a teletype. So they had to use tac to view something in reverse.

jlinkels

Last edited by jlinkels; 05-04-2018 at 02:09 PM.
 
Old 05-04-2018, 02:14 PM   #5
zaper
LQ Newbie
 
Registered: Sep 2017
Posts: 22

Original Poster
Rep: Reputation: Disabled
but linux was made in 1991 who still used teletypes ? or is it a unix carryover ?
 
Old 05-04-2018, 02:18 PM   #6
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by zaper View Post
yes i can also read a man page i meant why would you ever use it ? why is it there ?
Oh. Sorry. Mis-read your OP.
Frankly, I didn't know about it until this thread. I tend to use tail to see the most recent entries in a file, but I can see how tac could be useful, since tail still displays in chronological sequence, where the reverse display might well be useful...it is, after all, how I sort messages in my email clients

jlinkels: TTY? THAT brought back memories...paper tape and all
 
Old 05-04-2018, 02:21 PM   #7
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by zaper View Post
but linux was made in 1991 who still used teletypes ? or is it a unix carryover ?
It is a Unix carryover.

jlinkels
 
Old 05-04-2018, 02:23 PM   #8
zaper
LQ Newbie
 
Registered: Sep 2017
Posts: 22

Original Poster
Rep: Reputation: Disabled
ehm interesting why don't you just use a text editor and jump to last line ? not trying to be mean genuinely curios
 
Old 05-04-2018, 02:24 PM   #9
zaper
LQ Newbie
 
Registered: Sep 2017
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jlinkels View Post
It is a Unix carryover.

jlinkels
oh ok that makes sense thanks
 
Old 05-04-2018, 02:28 PM   #10
zaper
LQ Newbie
 
Registered: Sep 2017
Posts: 22

Original Poster
Rep: Reputation: Disabled
I'm just going to ask this here because i don't want to open another thread for something so minor but any idea why calling it with no argv does not write to stdin unlike cat ?

Last edited by zaper; 05-04-2018 at 03:08 PM.
 
Old 05-04-2018, 03:12 PM   #11
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by zaper View Post
ehm interesting why don't you just use a text editor and jump to last line ? not trying to be mean genuinely curios
What if you want to pipe the output to another process rather than read it in an editor?
 
Old 05-04-2018, 03:41 PM   #12
zaper
LQ Newbie
 
Registered: Sep 2017
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by hydrurga View Post
What if you want to pipe the output to another process rather than read it in an editor?
you cat the file and then pipe that into another program ?
 
Old 05-04-2018, 03:47 PM   #13
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by zaper View Post
you cat the file and then pipe that into another program ?
Imagine you want to process the data in a log file, but in reverse chronological order - tac fits the bill for piping the output to your data processor.

Imagine that you want to quickly look at the latest log. You know that something in the last x hours has caused the problem, but don't know when, so using tail is out of the question (how much tail would you want to see?) - tac piped through more fits the bill.

It may be seldom used, but tac still has its uses.
 
2 members found this post helpful.
Old 05-04-2018, 04:16 PM   #14
zaper
LQ Newbie
 
Registered: Sep 2017
Posts: 22

Original Poster
Rep: Reputation: Disabled
fair enough any idea what running it with no argv does ?
 
Old 05-04-2018, 04:26 PM   #15
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by zaper View Post
fair enough any idea what running it with no argv does ?
Your previous post talked about "writing to stdin". What does that mean, if I can ask?

If you run tac with no arguments, it takes its input from stdin.
 
  


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
operation of "tac" in sed dina3e Programming 7 08-24-2008 08:45 PM
Why my wireless card "atheros" run only as an acces point in "Master" mode. jardiamj Linux - Wireless Networking 3 11-11-2007 12:12 AM
kdenlive: on export, there's a tac tac tac in the sound output eantoranz Linux - Software 5 10-20-2007 11:20 AM
"Refer To" option to point questioners to existing discussion/material sboddy LQ Suggestions & Feedback 6 12-01-2005 02:14 AM
searching "TIC TAC TOE" bash script LV-chronos Linux - Newbie 5 05-29-2005 02:20 PM

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

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