![]() ![]() These can be combined using look-around assertions (described under Extended Patterns in the perlre manpage) to remove part of the grep pattern from what is determined to have matched for the purposes of -o. I am looking for FAST solution using grep or something else, and I need to pass the variable to this command in the cycle.Īlternative is to modify the imput file by replacing " -" by " _", but it is the last possibility I believe. GNU grep has the -P option for perl-style regexes, and the -o option to print only what matches the pattern. grep '' yourfilename The matches exact words.Time awk -F $'\t' -vsearch="YAL038W" '$1=search' inputfile > testfile.txt Time grep -w "YAL038W" inputfile > testfile.txt I also tried grep -x 'Written' file.txt and grep -E 'Written' file. I want to grep lines which have Written only, when i tried grep 'Written' file.txt, I got all the lines since written is present is with not written. Since many files contain database references, you might get a lot of data on output, so if you are only interested in all the files containing matching text. ip:port Written ip:port Not Written example : 127.0.0.1:80 Written. I've found solutions based on awk which are working fine, for example: awk -F $'\t' -vsearch=$name '$1=search' inputfileīut awk is terribly slow, over 10 times, see time measurements belowįor 2.5 Gb input file and > 5000 items to look for, script is already running for >24 hours!Įxample of inputfile: YAL038W-A 0 48 HWI-1KL176:101:CC27NACXX:3:2208:17646:92047 0 + I have file with ips and port number in the below format. it would work with " _" but not with " -". So, grep with -w option considers YAL038W identical to YAL038W-A, YAL038W-B since " -" is word separator. I was succesfully using grep -w "$name" inputfileįor that purpose until the case where strings have the following format (example): YAL038W but also YAL038W-A, YAL038W-B. I just need a row starting with a given string. ![]() I need to grep large tab-separated 6 columns file (*.bed file in fact) to split it by the content of the first column using the list of string variables (items). The problem looks simple and common, so I've looked through many answers but seems that none of them provides appropriate general solution. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |