LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 01-27-2018, 06:12 AM   #16
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,016
Blog Entries: 5

Rep: Reputation: 2859Reputation: 2859Reputation: 2859Reputation: 2859Reputation: 2859Reputation: 2859Reputation: 2859Reputation: 2859Reputation: 2859Reputation: 2859Reputation: 2859

Quote:
Originally Posted by Pomerano View Post
Actually, this was an old task given from one of the former teachers who used to work here. He was mostly known as 'Prf. Magic' because of his perception of achieving the unachievable. This could include unconventional methods of doing the simplest tasks using the most tedious and outdated methods: Such as this one.
He is now retired and lives somewhere in Spain with his hot and young wife, Nastasia. Most likely sipping piña coladas from her belly button on a daily basis

Thank you for the interest
Interesting. Even with Nastasia, he appears to have proved that achieving the unachievable is possible.

Do you have the exact wording of the task that he set?
 
Old 01-27-2018, 06:33 AM   #17
Pomerano
LQ Newbie
 
Registered: Jan 2018
Posts: 22

Original Poster
Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by pan64 View Post
still not sure what do you need. (for example you need the latest log files or the last lines of logfiles or what?).
By the way logrotate will drop out the old messages, so you will see only the latest in /var/log. Regardless of the command you use (awk/grep/perl/cat/whatever)
That is a very interesting suggestion. Would this still include cat somewhere on the line? - That is, without taking away its function of course. If so, would you please consider to put it in a formatted shell-command? Waiting to run an output?

Quote:
Originally Posted by pan64 View Post
still not sure what do you need. (for example you need the latest log files or the last lines of logfiles or what?).
My sincerest apologies. I only wish to reduce the output like so:
Quote:
Originally Posted by Pomerano View Post
Now, basically - in plain English - what I ultimately would like to do is...:
To reduce the number of the results who are triggered by the line command cat /var/log/messages. The only condition I have is that it cannot replace the command cat in any way.

In-kind regards - Pom

Last edited by Pomerano; 01-27-2018 at 06:40 AM.
 
Old 01-27-2018, 06:36 AM   #18
Pomerano
LQ Newbie
 
Registered: Jan 2018
Posts: 22

Original Poster
Rep: Reputation: Disabled
Thumbs down

Quote:
Originally Posted by hydrurga View Post
Interesting. Even with Nastasia, he appears to have proved that achieving the unachievable is possible.

Do you have the exact wording of the task that he set?

Unfortunately this was one for the books. All you hear are the tales
 
Old 01-27-2018, 08:32 AM   #19
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 5,251

Rep: Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903Reputation: 1903
By definition, cat dumps the entire contents of a file, so to limit output requires a second tool.
A UUOC, but
Code:
cat /var/log/messages | less +G
 
1 members found this post helpful.
Old 01-27-2018, 10:11 AM   #20
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
Display last few lines in a X terminal
Code:
cat - /var/log/messages <<< $'\e[0;10r\e[0J'

Last edited by keefaz; 01-27-2018 at 10:15 AM.
 
2 members found this post helpful.
Old 01-27-2018, 10:57 AM   #21
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 12,995

Rep: Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097
My God, I still don't understand. cat is just a simple reader, it will just read something (file, stdin) and push it toward to the next stage (pipe, file, whatever). The "thing" you need is - I think - something else.
 
Old 01-27-2018, 09:00 PM   #22
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
I still can't figure out what the object is. Do you want to show the most recent log entries in /var/log/messages? Then
Code:
$ cat /var/log/messages
will do that. It will scroll through the whole file, but whats displayed at the end will be the latest messages.
 
Old 01-28-2018, 09:14 AM   #23
Pomerano
LQ Newbie
 
Registered: Jan 2018
Posts: 22

Original Poster
Rep: Reputation: Disabled
Arrow

Quote:
Originally Posted by AwesomeMachine View Post
I still can't figure out what the object is. Do you want to show the most recent log entries in /var/log/messages? Then
Code:
$ cat /var/log/messages
will do that. It will scroll through the whole file, but whats displayed at the end will be the latest messages.
Thank you for the reply. Could this line of code have something added (without removing "cat") to ONLY show the very last results in that very output?
Because that is all I want.

Thanks again!
 
Old 01-28-2018, 09:24 AM   #24
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,635

Rep: Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205Reputation: 1205
Quote:
Originally Posted by Pomerano View Post
Thank you for the reply. Could this line of code have something added (without removing "cat") to ONLY show the very last results in that very output?
Because that is all I want.

Thanks again!
OH!
Code:
 cat /var/log/messages | tail -2
(-2, because you said results) The number can be anything, and if left off, defaults to 10.
Note that you can just
Code:
tail -2 /var/log/messages
to yield the same result.
 
1 members found this post helpful.
Old 01-29-2018, 03:37 PM   #25
jefro
Moderator
 
Registered: Mar 2008
Posts: 19,152

Rep: Reputation: 2921Reputation: 2921Reputation: 2921Reputation: 2921Reputation: 2921Reputation: 2921Reputation: 2921Reputation: 2921Reputation: 2921Reputation: 2921Reputation: 2921
Use more instead of cat maybe? Maybe less??
 
1 members found this post helpful.
Old 01-30-2018, 01:04 AM   #26
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 12,995

Rep: Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097Reputation: 4097
or most.
if you wish to use cat, you can do:
cat file | less +G
cat file | most
cat file | tail
but in call cases cat is just superfluous

Last edited by pan64; 01-30-2018 at 01:38 AM.
 
1 members found this post helpful.
Old 02-03-2018, 01:21 PM   #27
Pomerano
LQ Newbie
 
Registered: Jan 2018
Posts: 22

Original Poster
Rep: Reputation: Disabled
Lightbulb

Quote:
Originally Posted by scasey View Post
OH!
Code:
 cat /var/log/messages | tail -2
(-2, because you said results) The number can be anything, and if left off, defaults to 10.
Note that you can just
Code:
tail -2 /var/log/messages
to yield the same result.
This was a fantastic reply, however the real deal breaker was this part, simple as that! Thank you so much!
Quote:
Originally Posted by scasey View Post
OH!
Code:
 cat /var/log/messages | tail -2
From a historic point-of-view... this task was not solved by using a UUOC, like $ tail, or such. However, this was all I wanted to know. I will summarize my research for anyone else looking for anything similar at the very bottom...Case closed, thank you! (+1)

Last edited by Pomerano; 02-03-2018 at 01:24 PM.
 
Old 02-03-2018, 01:26 PM   #28
Pomerano
LQ Newbie
 
Registered: Jan 2018
Posts: 22

Original Poster
Rep: Reputation: Disabled
Lightbulb

Quote:
Originally Posted by jefro View Post
Use more instead of cat maybe? Maybe less??
Another fantastic reply! "More" did the trick! Thank you so much, Jefro! (+1)
 
Old 02-03-2018, 02:00 PM   #29
Pomerano
LQ Newbie
 
Registered: Jan 2018
Posts: 22

Original Poster
Rep: Reputation: Disabled
Lightbulb

Quote:
Originally Posted by keefaz View Post
Display last few lines in a X terminal
Code:
cat - /var/log/messages <<< $'\e[0;10r\e[0J'
This also worked, thank you! Although I just can't tell how, at the moment... (+1)
 
Old 02-03-2018, 02:03 PM   #30
Pomerano
LQ Newbie
 
Registered: Jan 2018
Posts: 22

Original Poster
Rep: Reputation: Disabled
Lightbulb

Quote:
Originally Posted by allend View Post
By definition, cat dumps the entire contents of a file, so to limit output requires a second tool.
A UUOC, but
Code:
cat /var/log/messages | less +G
"UUOC", thank you! Also, the code less did some of it, I just couldn't quite contain it to the extent of keeping it "less" (non-intentional pun) enough to serve its purpose. Although I replaced less +G with just less or less -1. Still very helpful, though, and I am certain that I am the blind one here. Therefore missing the solution. (+ 1)

Last edited by Pomerano; 02-03-2018 at 02:08 PM.
 
  


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
any cat people here ? one crazy cat s/woman/man/g here. ////// General 46 02-02-2018 11:13 AM
difference :: cat file_1 & cat < f_1 tushar_pandey Linux - Newbie 4 08-16-2012 09:19 AM
Cat 6 Cat 5e cable question babbab Linux - Networking 1 04-07-2010 02:33 PM
cat in asm/ cat --show-all option Tux Linux - Software 1 09-02-2006 09:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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