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 “!
Tag: awk
How can I check (and delete) if the last line (that contains the last occurence of a string) has a comma as last character?
I’ve been looking all over the internet but had no result. I’m trying to build a package generator (in shell/bash) and that respective package contains (one or more) json files. When browsing through a json file, if the user wants to delete one of the steps I must first take into consideration what if the step he wants to delete
Awk: How do I count occurrences of a string across columns and find the maximum across rows?
I have a problem with my bash script on Linux. My input looks like this: etc… which y=yes and n=no and that is the results of voting… and now I want with using awk to display the name and the total yes vote of each person (name) and the person that win (got the most y), any ideas? I do
how to rearrange all paragraphs from vertical to horizontal (all next to each other)
I have a file with about 25 paragraphs, they are separated by a blank line, each paragraph has about 2 to 20 lines, and each line has 5 columns separated by a semicolon.How can I move paragraph 2 next right to paragraph 1,paragraph 3 next right to paragraph 2 and so on. My goal is to paste everything later into
sh/awk (partly) script returning a null value but want it to return a value
I have the following sh script: the values that it is outputting looks like the following: As you can see it is returning a null value against the following line: This should look like the lines above and below. ([time] – [time] – [duration] etc) Which is in turn effecting the time calculation ( negative number) I need to put
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