Skip to content
Advertisement

Tag: grep

Comparing two files at end of line in Linux

I would like to compare two files and get the output of matching string in one of the files at the end of the line: Let’s say I have two files:- file1: file2: I could do something like this: This gives me the following output: This is because abcdef in file2 matches both of those lines in file1. However, what

Get information in the Log file

I have a log file and below is sample log in that file. I changed only here column 3rd and 4th as SourceNo,Destination for reference. my requirement – I need to get separately, Source wise total count that sent to Destination begin with 44 code. i tried with grep and awk but it didn’t work. appreciate your help. logs in

Select lines by condition and count with one line command

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

Recursively grep unique pattern in different files

Sorry title is not very clear. So let’s say I’m grepping recursively for urls like this: grep -ERo ‘(http|https)://[^/”]+’ /folder and in folder there are several files containing the same url. My goal is to output only once this url. I tried to pipe the grep to | uniq or sort -u but that doesn’t help example result: Answer If

Convert number from text file

I have a file: id name date 1 paul 23.07 2 john 43.54 3 marie 23.4 4 alan 32.54 5 patrick 32.1 I want to print names that start with “p” and have an odd numbered id My command: grep “^p” filename | cut -d ‘ ‘ -f 2 | …. result: paul patrick Answer Awk can do it all:

How to invert the l-flag of grep

First question here, so go easy (: I have a 385 files which are the result of simulations, named ###_result.dat. However, some of the results resulted in errors, which I can grep for using the -l flag since these files always contain the character “=”. So getting the error-files is no problem: When I want to list the files without

Advertisement