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
Tag: grep
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 word inside xml files in a folder
I know I can use grep to find a word in all the files present in a folder like this But my current directory has many sub-directories and I just want to search in all xml files present in the current directory and its all sub directories. How can I do that ? I tried this But it searches for
How to find which line is missing in another file
on Linux box I have one file as below A.txt Second file as below B.txt I want to know what is inside A.txt but not in B.txt i.e. it should print value 4 I want to do that on Linux. Answer didn’t test, give it a try
How to display modified date time with ‘find’ command?
With a find command, I can display directories names with multiple levels. The following command display all directories under /var path with a depth of 2: The result shows: With a stat command, I can find the modified date time: The result is: Is there a way to combine the two commands so that directories will be listed with modified
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