I have a log file consisting of a list of epoch 19-digit timestamps, for example I would like to iterate through this list, and compare the previous timestamp to the current timestamp in the list and echo a message if x duration of inactivity as occurred, ex: What would be the most efficient method to iterate through the list such
Tag: awk
How to replac rows of one csv file from another csv file based on a condition in linux(using awk or any other)?
first.csv second.csv required output.csv How to achieve above scenario like replace or adding rows from one CSV to another CSV file based on a condition in linux. Thanks in advance . I tried below command but its not working . Replacing same record for all rows which satisfies the condition. Answer Another awk
Renaming sub-directories recursively to a new pattern in bash
I want to rename sub-directories to my new pattern but some results may be dangerous in my own script: For example if I use /tmp/etc as input argument I would have the nasty results in the first iteration: So in next iteration there will not be /tmp/etc to work at. The second problem in my script is when I use
Skipping a part of a line using sed
I have a file with content like so – @1: 00001109 Each line is of the same format. I want the final output to be @1: 00 00 11 09. I used command in sed to introduce a space every 2 characters – sed ‘s/.{2}/& /g’. But that will give me spaces in the part before the colon too which
How do I grep/awk multiple lines from a cluster based on a pattern?
is there a way I can grep/awk multiple lines from a cluster based on a pattern? I have a file as follows: File.txt And the pattern is – “Dogs”, I would like the output to be: Is this possible? Answer or Notes: The first version loads the entire file into memory (but not the second). Both versions search the first
Search for log having value greater than certain time
Below is the sample log: Below is the desired output: When I use awk if it is exact time it will display the output otherwise it not displaying the output. Below is the code: Not displaying output: Displaying output: Besides that I got to find a solution. Below works but not as expected. Displaying output as expected: Displaying output. Expecting
AWK: Comparing substrings from two files and write to third file
I’m trying to compare two different files, let’s say “file1” and “file2”, in this way. If the substring of characters i.e 5 characters at position (8 to 12) matches in both files – file1 and file2, then remove that matching row from file 1. Finally, write the output to file3.(output contains the remaining rows which are not matching with file
implementing Excel if-like function with AWK
I have a question about Excel-if-function implementation with AWK. I have a csv file having eight columns like below: Each field can take only integer values from 1 to 6. I would like to give one point if the first column is 1. In other cases, the score would be zero. In this MWE case, the point for all three
How to add characters in word and replace it using sed command in linux
I have one requirement. I have one text file named as a.txt, which is having list of words – Now I have one another file named as b.txt , which is having content as Like this n of lines are there with different different words. Then I am writing script file – So after running script the output file of
Deleting the first row and replacing the first column data with the given data
I have the directories name like folder1,folder2,folder3….folder10. Inside each directory there are many text files with different names.And each text files contain a text row on the top and two columns of data that looks like as below Then what i want to do is== at first i want to remove completely the first row of all text files present