Skip to content
Advertisement

Tag: awk

Fastest way to extract pattern

What is the fastest way to extract a substring of interest from input such as the following? Desired output (i.e., the :-terminated string following the string MsgTrace(65/26) in this example): noop I tried the following, but without success: Answer grep by default returns the entire line when a match is found on a given input line. While option -o restricts

AWK – Show lines where column contains a specific string

I have a document (.txt) composed like that. And I want to show some information by column. For example, I have some different information in “info3” shield, I want to see only the lines who are composed by “test” in “info3” column. I think I have to use sort but I’m not sure. Any idea ? Answer You can use

Converting date format in bash

I have similar different file of the format backup_2016-26-10_16-30-00 is it possible to rename using bash script to backup_26-10-2016_16:30:00 for all files. Kindly suggest some method to fix this. Original file: backup_2016-30-10_12-00-00 Expected output: backup_30-10-2016_12:00:00 Answer To perform only the name transformation, you can use awk: As fedorqui points out in a comment, awk’s printf function may be tidier in

Storing awk manipulation in variable

I have two text files in tab delimted format like following. file_1 file_2 these two file contents were stored into two different variables. Now I would like extract the lines which has “+” symbol in column 4 and store it in the variable and later print it. But it throws me error message: Here is my code which I tried

Advertisement