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
Tag: grep
How to find sequence of characters matching an identifier in Linux/Unix?
I have a fasta file called mytext.fasta. mytext.fasta When I do grep -A1 ‘SS1G_01082’ mytext.fasta, I get: Instead I want to get: If you notice, every sequence starts with > in this file, so I want to get the full length of sequence when I do grep. How can I get this done? Answer It is easier with gnu awk
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
Fast way to grep gzipped files in reverse piped to tail/head
I need to search a folder of gzipped files for a string, however I need to search starting at the bottom of each file. I then need the command to return results when it has 10 matches. So far I have this: I’m using zcat to get all the file contents, and then I use tac to reverse them. This
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
Search for a mention of each filename contained in a directory, in every file in the directory
I’m trying to perform a search in my directory, to count the total number of times each individual file is referenced within the contents of all the files in the directory. Essentially, I’m trying to more efficiently recreate the copy and paste of each ‘filename’ into the ‘search in this folder’ that I am currently doing, as there are around
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
How to grep for a matching word, not the surrounding line, with a wildcard?
Maybe an odd question, but I’m attempting to grep the output of a command to select just the matching word and not the line. This word also has a wildcard in it. The first and second sections of the command check the git log for a file and grabs the line pertaining to the date and time of creation. I’m
Grep for String and open at the corresponding line
I’m having several occurrences of a specific string over several files in several lines obtained with grep. I’d like to open these files sequencially on the corresponding lines. I tried to do it with vim, but so far no success when it comes to open the line. Mustn’t be vim or grep, but I’d assume there must be some kind