Here are a couple of ways to do it that match the requested output format a little closer:
If this fails because the expansion of *.log exceeds ARG_MAX limitations, you can use this instead:
If you don't want an empty line between reports for separate files, comment out or remove the code shown in red.
Although written for ksh, both of these will also work with bash or any other shell that supports standard POSIX shell syntax.
This User Gave Thanks to Don Cragun For This Post:
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)