I need help with analyze nginx logs. Sample of log: Is it possible to select with count all uniq ip addresses which contain per_page parameter and this parameter equal or greater than 100? So, the output can be in any format: Is it possible to get with one command? Answer This is absolutely basic awk – read the book Effective
Tag: sed
Comparing two files and updating second file using bash and awk and sorting the second file
I have two files with two colums in each file that I want to compare the 1st column of both files. If the value of the 1st column in the first file does not exist in the second file, I then want to append to the second file the value in the 1st column of the first file, eg firstFile.log
Select first match between two patterns.Restart search if a 3rd pattern is found using sed/awk/grep
I am struggling with the following task(I’ve been searching for answer for a while). The search is for text between START_PATTERN and END_PATTERN1 Having a file structured like this: The task would be to restart search if END_PATTERN2 is found. Thus the command output should be: Thank you for your time! Answer this line should work for your example: test:
Remove string in file on linux
I am looking to remove the _id field and its value which changes: I would like to use sed or any other command. Answer It is easy with jq. O/P:
Match two lines, replace with three lines
I need to use sed to replace every matching two-line pattern with a three line pattern. Here’s my input file (tempfile.txt). Basically, if a client-hostname “HOSTNAME”; is missing, then it should be replaced with a tab and then a newline. My attempt: sed ‘N; /hardware.*}/d; P; D’ tempfile.txt The result is: This is my desired output. So as you can
How do you use wget to download most up to date file on a site?
Hello I am trying to use wget to download the most update to day McAfee patch and I am having issues singling out the .tar file. This is what I have: However when I run the above command it gives me: When I need it to just be the most recent.tar file in between the <a> </a> which in this
sed substitute with partial string
Is it possible to replace the last 5 characters of the line with the last 4 characters of the line in sed? My filenames can be any length but the end is always predictable i.e. the part I want to substitute is always 5 characters from the end Answer Just match them separately, and omit the undesired character: Another approach
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 “!
How to delete prefix, suffix in a string matching a pattern and split on a character using sed?
I have the following string, which is the output of a cassandra query in bash I want to split this string so as to remove the string in the beginning till the last + symbol and then remove the tail end, which is (XYZ rows). So, the string becomes A|1|a B|2|b C|3|c D|4|d. Now, I want to split this string
Sed command in linux
How do I extract URL’s from a file? My file name is URL_name.txt This file has a lot of url inside. It looks like this: Here is my idea, I want to remove everything before URLs then I can remove everything after URL. How do I use sed command deal with it? The output should be http://www.google.com/ http://www.stackoverflow.com/ Answer You