Sponsored Content
Top Forums Shell Programming and Scripting Print two matched words from the same line Post 302367541 by summer_cherry on Tuesday 3rd of November 2009 02:27:20 AM
Old 11-03-2009
Code:
while(<DATA>){
	my @tmp = split;
	print join " ", grep {length($_) eq 6} @tmp;
	print "\n";
}
__DATA__
O14757 hsa04110 hsa04115 2 P38398 hsa04120 1 
O15111 hsa04010 hsa04210 hsa04920 hsa04620 hsa04660 hsa04662 hsa05200 hsa05212 hsa05221 hsa05220 hsa05215 hsa05222 hsa05120 13 O14920 hsa04010 hsa04210 hsa04910 hsa04920 hsa04620 hsa04660 hsa04662 hsa05200 hsa05212 hsa05221 hsa05220 hsa05215 hsa05222 hsa04930 hsa05120 15 
O15264 hsa04010 hsa04370 hsa04912 hsa04620 hsa04664 hsa04670 hsa05014 hsa05120 8 Q15139 
O15297 hsa04115 1 Q00987 hsa04120 hsa04110 hsa04115 hsa05200 hsa05214 hsa05220 hsa05218 hsa05219 hsa05215 9 
O43464 hsa05012 1 P98170 hsa04120 hsa04210 hsa04510 hsa05200 hsa05222 5

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

print only last two words of a line

can u help me out to print last two words of each sentence of a file. for example. contents of input file: i love songs my favourite songs sent songs all kind good buddy Ouput file should contain: love songs favourite songs sent all kind good buddy (5 Replies)
Discussion started by: pradeepreddy
5 Replies

2. Shell Programming and Scripting

How to print the words in the same line with space or to the predefined line?

HI, cat test abc echo "def" >> test output is cat test abc def the needed output is cat test abc def and so on (5 Replies)
Discussion started by: jobycxa
5 Replies

3. Shell Programming and Scripting

AWK Print Line If Specific Character Is Matched

Hello, I have a file as such: FFFFFFF6C000000 225280 225240 - - rwxs- FFFFFFFF79C00000 3240 3240 - - rwxs- FFFFFFFF7A000000 4096 4096 - - rwxs- FFFFFFFF7A400000 64 64 ... (3 Replies)
Discussion started by: PointyWombat
3 Replies

4. Shell Programming and Scripting

print number of words in each line

Hi, Please suggest a way to print number of words in the end of each line. <input file> red aunt house blue sky bat and ball game <output file> red aunt house 3 blue sky 2 bat and ball game 4 Thanks! (2 Replies)
Discussion started by: mira
2 Replies

5. Shell Programming and Scripting

Print only matched string instead of entire line

Hi, I have a file whose lines are something like Tchampionspsq^@~^@^^^A^@^@^@^A^A^Aÿð^@^@^@^@^@^@^@^@^@^@^A^@^@^@^@^?ð^@^@^@^@^@^@^@?ð^@^@^@^@^@^@pppsq^@~^@#@^@^@^@^@^@^Hw^H^@^@^@^K^@^@^@^@xp^At^@^FTtime2psq^@ ~^@^^^A^@^@^@^B^A I need to extract all words matching T*psq from the file. Thing is... (4 Replies)
Discussion started by: shekhar2010us
4 Replies

6. Shell Programming and Scripting

Print line between two patterns when a certain pattern matched

Hello Friends, I need to print lines in between two string when a keyword existed in those lines (keywords like exception, error, failed, not started etc). for example, input: .. Begin Edr ab12 ac13 ad14 bc23 exception occured bd24 cd34 dd44 ee55 ff66 End Edr (2 Replies)
Discussion started by: EAGL€
2 Replies

7. Shell Programming and Scripting

Regex: print matched line and exact pattern match

Hi experts, I have a file with regexes which is used for automatic searches on several files (40+ GB). To do some postprocessing with the grep result I need the matching line as well as the match itself. I know that the latter could be achieved with grep's -o option. But I'm not aware of a... (2 Replies)
Discussion started by: stresing
2 Replies

8. UNIX for Advanced & Expert Users

To print from the first line until pattern is matched

Hi I want to print the line until pattern is matched. I am using below code: sed -n '1,/pattern / p' file It is working fine for me , but its not working for exact match. sed -n '1,/^LAC$/ p' file Input: LACC FEGHRA 0 LACC FACAF 0 LACC DARA 0 LACC TALAC 0 LAC ILACTC 0... (8 Replies)
Discussion started by: Abhisrajput
8 Replies

9. Shell Programming and Scripting

How to print two matched patterns only from each line?

My input looks like this. # Lot Of CODE Before AppType_somethinglese=$(cat << EOF AppType_test1='test-tool/blatest-tool-ear' AppType_test2='test/blabla-ear' # Lot Of CODE After I want to print text betwen 1) _ and = and 2)/ and ' from each line and exclude lines with "EOF". Output... (2 Replies)
Discussion started by: kchinnam
2 Replies

10. Shell Programming and Scripting

How to print previous line of multiple pattern matched line?

Hello, I have below format log file, Comparing csv_converted_files/2201/9747.1012H67126.5077292103609547345.csv and csv_converted_files/22019/97447.1012H67126.5077292103609547345.csv Comparing csv_converted_files/2559/9447.1012H67126.5077292103609547345.csv and... (6 Replies)
Discussion started by: arvindshukla81
6 Replies
NBIBFIND(1)						      General Commands Manual						       NBIBFIND(1)

NAME
nbibfind - find bibliography entries for BibTeX or NbibTeX SYNOPSIS
nbibfind [-terse|-full|-bib] query [bibname...] DESCRIPTION
nbibfind searches for BibTeX entries using the same query algorithm as NbibTeX. If the optional list of bibnames is given, it searches only those bibliographies; otherwise, it searches all bibliographies on the user's BIBINPUTS (or on the standard system path). The lan- guage of query is that of nbibtex(1). OPTIONS
-terse Print a one-line summary of each matched entry (the default). -full Print a longer summary of each matched entry, including full authors, year, and title, possibly spread over multiple lines. -bib Print each entry in a form suitable for including in a .bib file. EXAMPLES
nbibfind author=knuth:series=art-programming:volume=2 nbibfind knuth:seminumerical personal.bib nbibfind harper-moggi:phase nbibfind :essence-algol nbibfind :essence-functional QUERY LANGUAGE
The query language is that of nbibtex(1). A query consists of a sequence of one or more constraints separated by colons. A constraint may be empty. A nonempty constraint is of the form key=words, where key is the name of a field in the NbibTeX entry and words is a sequence of one or more words separated by dashes. The contraint is satisfied if every word in words is found in the field named by key. (The key may also be [type], which matches agains the type of the entry, or *, which looks for words in any field.) As a convenience, keys may be defaulted in up to three constraints. In the first constraint, the default key is author. In the second constraint, the default key is year if words is all digits, and is title otherwise. In the third constraint, the default key is year if words is all digits, and is [type] otherwise. To match a word in words, nbibfind uses the Boyer-Moore string-matching algorithm, so longer words are usually faster. ENVIRONMENT
For .bib files, nbibfind uses the BIBINPUTS environment variable if that is set, otherwise the default. For details of the searching, see tex(1) and kpsewhich(1). SEE ALSO
nbibtex(1), latex(1), tex(1), kpsewhich(1), bibtex(1). Leslie Lamport, LaTeX - A Document Preparation System, Addison-Wesley, 1985, ISBN 0-201-15790-X. AUTHOR
Norman Ramsey, Harvard University. 4 May 2006 NBIBFIND(1)
All times are GMT -4. The time now is 01:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy