Every line has a word and a number. I need somehow to select the nth letter which all together will make a new word. For example: it has to start like this and I’m only allowed to use sed (no awk, perl, …). I know how to select all the numbers or the text and I was thinking about but
Tag: sed
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 remove commas in the middle of a specific line in a file in linux/unix
Someone was trying to be helpful in their test description. However, they added commas to the description so that when the test description is outputted to the log file, the results have extra commas. This makes it difficult to parse the results since the number of commas vary in the results file. I want to use sed and go into
linux sed, do insert and append at the same time
I have a question about linux sed command. I just want to insert something before every line and append something after every line. And i want to do these things at the same time. For example, assume file.txt is like: I need to output: so I think the command should be like: But the result is not right, a is
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 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
find matching text and replace next line
I’m trying to find a line in a file and replace the next line with a specific value. I tried sed, but it seems to not like the n. How else can this be done? The file looks like this: And I’d like to change it to this Here’s what I tried: Answer This might work for you (GNU sed):
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
Use sed with ignore case while adding text before some pattern
In this case,how to ignore case while searching for pattern =first Answer You can use the following: Otherwise, you have the /I and n/i flags: From man sed: I i The I modifier to regular-expression matching is a GNU extension which makes sed match regexp in a case-insensitive manner. Test
How to append text to a specific lines in a file using shell script?
I have a text file (file.txt) having content something like: It contains the process and respective PID. Using shell script, I want to append a string (running/not running) to that lines in this file, according to the PID. For example, in the above file, for line containing PID 3696, I want to append a string “running” at the end, so