Skip to content
Advertisement

Tag: grep

searching through text file in terminal

Hi this might be a basic question for many, but it has however managed to eat a couple of hours of my time. I have large data file as an output from running a script. The file contains around 15 columns and around 100,000 rows. I wish to search through the file and in columns 4,5,6,7 and 8 check for

How to grep a string in a program?

Description: The str_buf_to_grep is given in any way, which might be the content of a text file, and might be very long and complex, even contains special characters, such as |, “, etc. I want to use the grep command to find matched lines, and the patterns might be very complex. How should I implement it? Answer Use popen: The

how to grep lines according to 6th field contents

I would like to know how to filter lines according to the mem usage: I would like to be able to find only the PIDs that (RES mem usage) exceed 5GB Explicitly, I have the following lines and I’d like to grep only the lines where the 6th field is larger than 5 GB EDIT: Note that sorting is not

filter file with specift words linux

I have files in which the first column is an ID, and the second column is an option, like this: and I need to create a files with the IDs depending with the option. It is to say: I try with cat file.txt | grep -w “option” > file_option but the problem is that the files are mutually exclusive, and

grep -A until a string

assuming that we have a file containing the following: and we want to grep this file so we take the lines from chapter 1 blah blah to blah num (the line before the next chapter). The only things we know are the stating string chapter 1 blah blah somewhere after that there is another line starting with chapter a dummy

Print previous line if condition is met

I would like to grep a word and then find the second column in the line and check if it is bigger than a value. Is yes, I want to print the previous line. Ex: Input file Output Now, I want to search for BB and if the second column (2 or 0.1) in that line is bigger than 1,

How to clean up masscan output (-oG)

I have a problem with the output produced by the masscan utility with the -oG options (“grep-able” output); for instance, it outputs this: The above is neither very readable nor easy to understand. How can I use Linux command-line utilities, e.g. sed, awk, or grep, to output something as follows, using the file above? As you can see, the output

how to escape single quotes in grep

I found a few questions here similar to this but they are not quite identical. I want to grep for the text ‘true’ format in certain files. How do I do it? Not sure how to escape the single quotes around true. Answer Just wrap the string within double quotes: Test

Advertisement