Sponsored Content
Top Forums Shell Programming and Scripting Print n lines from top and n lines from bottom of all files with .log extenstion Post 302887840 by kraljic on Tuesday 11th of February 2014 06:41:44 AM
Old 02-11-2014
Print n lines from top and n lines from bottom of all files with .log extenstion

Oracle Linux 6.4

In a directory I have more than 300 files with the extension .log

I want the first 5 and last 5 lines of these .log files to be printed on screen with each file's name.

Expected output :

Code:
Printing first 5 and last 5 lines of FX_WT_Feb8_2014.log

 !! Authentication dialogue with 10.79.60.158 failed
   R:  !! Failed to pull policy from policy server
   R:  !! Did not start the scheduler
   There is no readable input file at promises.cf
    !!! System error for stat: "No such file or directory"
   
 
 !! Authentication dialogue with 10.79.60.158 failed
    R:  !! Failed to pull policy from policy server
    R:  !! Did not start the scheduler
    cf-agent was not able to get confirmation of promises from cf-promises, so going to failsafe
There is no readable input file at promises.cf

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep for a particular pattern and remove few lines above top and bottom of the patter

grep for a particular pattern and remove 5 lines above the pattern and 6 lines below the pattern root@server1 # cat filename Shell Programming and Scripting test1 Shell Programminsada asda dasd asd Shell Programming and Scripting Post New Thread Shell Programming and S sadsa ... (17 Replies)
Discussion started by: fed.linuxgossip
17 Replies

2. Shell Programming and Scripting

print lines AFTER lines cointaining a regexp (or print every first and fourth line)

Hi all, This should be very easy but I can't figure it out... I have a file that looks like this: @SRR057408.1 FW8Y5CK02R652T length=34 AGCAGTGGTATCAACGCAGAGTAAGCAGTGGTAT +SRR057408.1 FW8Y5CK02R652T length=34 FIIHFF6666?=:88@@@BBD:::?@ABBAAA>8 @SRR057408.2 FW8Y5CK02TBMHV length=52... (1 Reply)
Discussion started by: kmkocot
1 Replies

3. Shell Programming and Scripting

Search for string and print top and bottom line

Hi Folks I need a one liner to parse through a log and if the string is found print the line above, the line with the string and the line below. example: The ball is green and blue Billy through the ball higer. Jane got hurt with the ball. So if I search for Billy I would need the 3... (1 Reply)
Discussion started by: bombcan
1 Replies

4. Shell Programming and Scripting

Remove x lines form top and y lines form bottom using AWK?

How to remove x lines form top and y lines form bottom. This works, but like awk only cat file | head -n-y | awk 'NR>(x-1)' so remove last 3 lines and 5 firstcat file | head -n-3 | awk 'NR>4' (5 Replies)
Discussion started by: Jotne
5 Replies

5. Shell Programming and Scripting

Copy/print all lines between pattern is found in .log files

Hi, I have a folder with multiple (< 33) .log files. And I have to copy the lines between two patterns from all the .log files to a new file. (script file with a loop?) Thanks in advance. 1.log ... .. xx1> begin ... .. .. >>> Total: 2 Alarms .. .. (17 Replies)
Discussion started by: AK47
17 Replies

6. Shell Programming and Scripting

Print first 20 lines from all .log files

RHEL 5.8 In a directory I have more than 200 files with the extension .log Using head command I want to print first 20 lines of each log file. For each .log file, it should print like below Printing first 20 lines of : GRP_error_April29.log Apr 29 04:02:05 raptor03b syslogd 1.4.1:... (4 Replies)
Discussion started by: John K
4 Replies

7. Shell Programming and Scripting

How to print from bottom to top?

Hi, i have a file which contains PID and wanted to execute kill command. but the thing is, when killing PID's needs to kill PID from bottom to top. Please help INPUT 21414 sh -c extract.ksh ASA 21416 /bin/ksh extract.ksh ASA 21428 /usr/bin/perl -w /var/tmp/tempperl.21416 ASA... (4 Replies)
Discussion started by: reignangel2003
4 Replies

8. UNIX for Dummies Questions & Answers

awk - (URGENT!) Print lines sort and move lines if match found

URGENT HELP IS NEEDED!! I am looking to move matching lines (01 - 07) from File1 and 77 tab the matching string from File2, to File3.txt. I am almost done but - Currently, script is not printing lines to File3.txt in order. - Also the matching lines are not moving out of File1.txt ... (1 Reply)
Discussion started by: High-T
1 Replies

9. UNIX for Beginners Questions & Answers

Print number of lines for files in directory, also print number of unique lines

I have a directory of files, I can show the number of lines in each file and order them from lowest to highest with: wc -l *|sort 15263 Image.txt 16401 reference.txt 40459 richtexteditor.txt How can I also print the number of unique lines in each file? 15263 1401 Image.txt 16401... (15 Replies)
Discussion started by: spacegoose
15 Replies

10. UNIX for Beginners Questions & Answers

How to print lines from a files with specific start and end patterns and pick only the last lines?

Hi, I need to print lines which are matching with start pattern "SELECT" and END PATTERN ";" and only select the last "select" statement including the ";" . I have attached sample input file and the desired input should be as: INPUT FORMAT: SELECT ABCD, DEFGH, DFGHJ, JKLMN, AXCVB,... (5 Replies)
Discussion started by: nani2019
5 Replies
uulog(1)						      General Commands Manual							  uulog(1)

NAME
uulog - display entries in the UUCP log file. SYNOPSIS
uulog [-#] [-n lines] [-sf system] [-u user] [-DSF] [--lines lines] [--system system] [--user user] [--debuglog] [--statslog] [--follow] [--follow=system] DESCRIPTION
The uulog program can be used to display entries in the UUCP log file. It can select the entries for a particular system or a particular user. You can use it to see what has happened to your queued jobs in the past. Different options may be used to select which parts of the file to display. OPTIONS
-#, -n lines, --lines lines Here '#' is a number; e.g., `-10'. The specified number of lines is displayed from the end of the log file. The default is to dis- play the entire log file, unless the -f, -F, or --follow options are used, in which case the default is to display 10 lines. -s system, --system system Display only log entries pertaining to the specified system. -u, --user user Display only log entries pertaining to the specified user. -D --debuglog Display the debugging log file. -S, --statslog Display the statistics log file. -F, --follow Keep displaying the log file forever, printing new lines as they are appended to the log file. -f system, --follow=system Keep displaying the log file forever, displaying only log entries pertaining to the specified system. Standard UUCP options: -X type, --debug type Turn on particular debugging types. The following types are recognized: abnormal, chat, handshake, uucp-proto, proto, port, config, spooldir, execute, incoming, outgoing. --debug option may appear multiple times. A number may also be given, which will turn on that many types from the foregoing list; for example, --debug 2 is equivalent to --debug abnormal,chat. -I file, --config Set configuration file to use. -v, --version Report version information and exit. --help Print a help message and exit. SEE ALSO
uucp(1) AUTHOR
Ian Lance Taylor <ian@airs.com>. Text for this Manpage comes from Taylor UUCP, version 1.07 Info documentation. Taylor UUCP 1.07 uulog(1)
All times are GMT -4. The time now is 04:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy