Skip to content
Advertisement

Tag: grep

Get lines that end with “$” in a text file

I have an output like this: What i want is just this line: To be more clear, I want those line ending with a specific string. I want to grep lines that have a / character at their last column. Answer You can use $ like this: As $ stands for end of line, /$ matches those lines whose last

Adding additional newline between each line

I am analyzing log files from my server(particular few lines from there). But those lines are having around 1000 to 2000 characters in length. Here is an example how the lines are coming out with grep and less with following command. Output: But its hard for me to separate them as those are screen full of texts(also not pleasant for

How to grep a group of files within a specific time range

I’m trying to write a script used on a buffer box that does full packet capture of network traffic. As it’s for a fairly big network we split the captures into 100MB segments. At times of high network traffic oftentimes over a one minute period we will have multiple pcaps which cover that period. So what I want to do

grep without showing path/file:line

How do you grep and only return the matching line? i.e. The path/filename is omitted from the results. In this case I want to look in all .bar files in the current directory, searching for the term FOO Answer No need to find. If you are just looking for a pattern within a specific directory, this should suffice: Where -h

How do I grep out multiple lines of the same pattern?

I have a log file that is filled with exceptions that is not useful to me. It is being generated every two second and when looking at log file that contains 24 hrs of logging it becomes overwhelming to get to the relevant info I need. My logs look something like this: I want to clean up the copy of

bash: grep exact matches based on the first column

I have a .txt file like below: For example, I want to generate a subset with the IDs 4324321_A3 and 9342432 (based on the first column!). I tried the following command to find the exact matches: But when I use this line, I end up with a dataset like this: The problem is that the line that matches a part

Grep inside all files created within date range

I am on the Ubuntu OS. I want to grep a word (say XYZ) inside all log files which are created within date range 28-may-2012 to 30-may-2012. How do I do that? Answer This is a little different from Banthar’s solution, but it will work with versions of find that don’t support -newermt and it shows how to use the

Advertisement