Skip to content
Advertisement

Tag: grep

Fetch latest matching string value

I have a file which contains two values for initial… keyword. I want to grab the latest date for matching initial… string. After getting the date I also need to format the date by replacing / with – In the above example, my output should be 2018-02-05. Here, I am fetching the line which contains initial… value and only getting

grep -v with while read line command not working properly

I use this command to remove lines from (target.txt) that match string in (removefrom.txt) This is (target.txt) This is (removefrom.txt) This is the result should look like: But sometimes the resule is like: or or I ever try to use sed, but the problem is still there, It didn’t remove lines properly. Answer grep -vf removefrom.txt target.txt

Sending linux commands in Perl – Grep piped to grep

The basic code: Why wont Perl complete these commands correctly? $fail2ban is already defined to 0, so that’s not the issue. The fail2ban.log does contain a line that should match(when running command from shell it matches): The error i keep getting is: All the commands run fine from bash/shell, seems at if perl is not happy with grep being piped

Running variable string match against grep search?

I’ve defined the variables here to shorten the logic a little. The wget works fine (downloads the correct file) and grepping for tar.gz works in the wget.log The issue is the match to another file! Basically, if it’s on a blacklist I want it to skip! Answer Use && to test if both of the grep commands succeed I’ve used

grep command in linux using ” in regex

I have the following linux cmd: The text i have is the following: Of course the output i want to have is: Why dont i have the correct output? Because of the ” required by the grep which mix with ” in my text? How to fix it? Answer You could use the following regex: Original poster provided a regex

Advertisement