Sponsored Content
Top Forums Shell Programming and Scripting Print two matched words from the same line Post 302367289 by pludi on Monday 2nd of November 2009 05:26:23 AM
Old 11-02-2009
Assuming that the number of spaces between the matches in the line don't matter:
Code:
perl -lne '@a=(/([A-Z0-9]{6})/g); print "@a"' test.txt
O14757 P38398
O15111 O14920
O15264 Q15139
O15297 Q00987
O43464 P98170

 

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
MAN(7)							 Miscellaneous Information Manual						    MAN(7)

NAME
man - macros to typeset manual SYNOPSIS
nroff -man file ... troff -man file ... DESCRIPTION
These macros are used to lay out pages of this manual. A skeleton page may be found in the file /usr/man/man.template. Any text argument t may be zero to six words. Quotes may be used to include blanks in a `word'. If text is empty, special treatment is applied to the next input line with text to be printed. In this way .I may be used to italicize a whole line, or .SM may be followed by .B to make small bold letters. A prevailing indent distance is remembered between successive indented paragraphs, and is reset to default value upon reaching a non- indented paragraph. Default units for indents i are ens. Type font and size are reset to default values before each paragraph, and after processing font and size setting macros. These strings are predefined by -man: *R `(Reg)', trademark symbol in troff. *S Change to default type size. FILES
/usr/share/tmac/tmac.an /usr/man/man.template SEE ALSO
troff(1), man(1) BUGS
Relative indents don't nest. REQUESTS
Request Cause If no Explanation Break Argument .B t no t=n.t.l.*Text t is bold. .BI t no t=n.t.l. Join words of t alternating bold and italic. .BR t no t=n.t.l. Join words of t alternating bold and Roman. .DT no .5i 1i...Restore default tabs. .HP i yes i=p.i.* Set pre- vailing indent to i. Begin paragraph with hanging indent. .I t no t=n.t.l. Text t is italic. .IB t no t=n.t.l. Join words of t alternating italic and bold. .IP x i yes x="" Same as .TP with tag x. .IR t no t=n.t.l. Join words of t alternating italic and Roman. .LP yes - Same as .PP. .PD d no d=.4v Interparagraph distance is d. .PP yes - Begin paragraph. Set prevailing indent to .5i. .RE yes - End of relative indent. Set prevailing indent to amount of starting .RS. .RB t no t=n.t.l. Join words of t alternating Roman and bold. .RI t no t=n.t.l. Join words of t alternating Roman and italic. .RS i yes i=p.i. Start relative indent, move left margin in distance i. Set prevailing indent to .5i for nested indents. .SH t yes t=n.t.l. Subhead. .SM t no t=n.t.l. Text t is small. .TH n c x v m yes -Begin page named n of chapter c; x is extra commentary, e.g. `local', for page foot center; v alters page foot left, e.g. `4th Berkeley Distribution'; m alters page head center, e.g. `Brand X Programmer's Manual'. Set prevailing indent and tabs to .5i. .TP i yes i=p.i. Set prevailing indent to i. Begin indented paragraph with hanging tag given by next text line. If tag doesn't fit, place it on separate line. * n.t.l. = next text line; p.i. = prevailing indent 7th Edition October 22, 1996 MAN(7)
All times are GMT -4. The time now is 08:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy