Skip to content
Advertisement

Tag: awk

Grep lines from a file in batches according to a format

I have a file with contents as: Hi welcome ! Chunk Start Line 1Line2! Chunk Start Line 1 Line 2 Line 3 ! Chunk Start Line 1Line 2Line 3Line 1Line 2Line 3Line 4Line 5Line 1Line 2Line 3Line 4 Now, everything beginning with “! Chunk Start” and before the next “! Chunk Start” is a chunk, i.e. the lines between “!

Grep across multiple lines but returning all matches

I’m trying to grep against a windows file under cygwin or linux, to find all MySQL statements between a table lock and table unlock in a mysql log. I can use awk, but I need the line numbers from the original file I don’t see why -Pzo isn’t working in cygwin Effectively I’m looking for is a way to locate

awk sep data extracting lines after certain variable

I have a large file that has some regular pattern These line are repeated among other lines above and below. I need to print the snaps1 line and also get the instance: line So I need to search for snaps1 but only if counter is greater than 0 and then print snaps1 line and also the instance line. Sorry have

Date manipulation in awk variable : Non Military Format

In the mentioned code : | awk ‘{ print $1, $2 }’ AWK $2 is having “Thu Nov 19 17:00:00 2015” in it. I want to manipulate this date String there only in inline awk in Non Military format “Thu Nov 19 05:00:00 PM 2015”. Please help. Answer This line should give you the expected format: Here you go:

Regular expression to search column in text file

I am having trouble getting a regular expression that will search for an input term in the specified column. If the term is found in that column, then it needs to output that whole line. These are my variables: the text file is in this format with a space being the field seperator, with many contact entries: I’ve tried with

script to change format of text [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 7 years ago. Improve this question I want to change a text file that contains for example : a 1 b 2 a 3 b 4 to: a b 1 2

Advertisement