Skip to content
Advertisement

Tag: grep

Regular expression operator {} in linux bash

I’m having some problems with the {} operator. In the following examples, I’m trying to find the rows with 1, 2, and 2 or more occurrences of the word mint, but I get a response only if I search for 1 occurrence of mint, even though there are more than 1 per row. The input I am processing is a

reading and analyzing a text file with bash script

I want to read a log file and want to extract 5-6 number digit that is written right next after the keyword “salary”. And then want to analyze if the salary is above 2000. If there is even one above 2000, it is a MNC otherwise unknown. After writing the salary, the line ends mostly but sometimes there is an

How to replace newlines between brackets

I have log file similar to this format Here is the echo command to produce that output $ echo -e “test {nseq-cont {nttt0,nttt67,nttt266nttt},nttgrp-id 505nt}n}ntest{nttest1{nttvalnt}n}n” Question is how to remove all whitespace between seq-cont { and the next } that may be multiple in the file. I want the output to be like this. Preferably use sed to produce the output.

Filter followed tail to file using grep and redirect

I want to get the output of tail -f /var/log/apache2/error.log | grep “trace1” into a file. But tail -f /var/log/apache2/error.log | grep “trace1” > output.txt does not work, while the first command gives an output in my terminal window as expected. I guess it has to do with the follow-parameter, because if I omit the “-f”, the output file is

linux replace string in files recursively

I have a folder which is full of *.java files. it has the following method in it: i wanted to change this as following: I have searched in the forum and found some solutions, replce string is what i wanted so tried the following: But it throwing me the following error: I guess the old_string and new_string formates are the

using only ‘grep’ command to get specific column

This below shows this some lines of csv file, i want to get the results that only get the Population column with only using grep command. results i want: The command i made for this problem was which got results below how can i get rid of the rest of things without using awk sed or any other things? Answer

Replacing line of text cointing using sed

I’m trying to replace document.querySelector(‘.popup’).classList.add(‘active’) by document.querySelector(‘.popup’).classList.add(‘noactive’) Answer You can use See the online demo. The regex is POSIX BRE compliant and matches (document.querySelector(‘.popup’).classList.add(‘) – Group 1 (1): a literal document.querySelector(‘.popup’).classList.add(‘ text (active’)) – Group 2 (2): a literal active’) text. Note the capturing groups in a POSIX BRE regex are set with (…). The literal dots need escaping and

Advertisement