LinuxQuestions.org
Help answer threads with 0 replies.
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-17-2007, 09:56 AM   #16
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978

Yes, it is Unix! First of all you may check if there is the command ggrep (it is not a typo: ggrep with double g) that is the GNU version of grep that could be installed on Unix. In this case use ggrep instead of grep in the example above.

If not, here is a little gawk code that does the trick:

Code:
/Xml To Publish : / {
        for (i = 5; i > 0; i--)
            if ( (NR - i) in lines ) {
               print lines[NR - i]
              delete lines[NR - i]
           }
       below = NR + 5
  }
  
  NR <= below { print; next }

  { lines[NR] = $0 }
Save this in a file called (e.g.) script.awk, then execute the command

Code:
awk -f script.awk mylogfile.log
But sincerely I don't know if it works with the awk on Unix. I tested it with gawk (the GNU version of awk). Check if the command gawk exists on the Unix machine:

Code:
which gawk
 
  


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
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 03:23 AM
unix command to linux command leonidas Linux - General 1 09-10-2004 01:40 AM

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

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