Sponsored Content
Top Forums Shell Programming and Scripting Print word 1 in line 1 and word 2 in line 2 if it matches a pattern Post 302349072 by bangaram on Monday 31st of August 2009 04:16:18 AM
Old 08-31-2009
Quote:
Originally Posted by protocomm
Rather this...

Code:
awk '{ORS=""} /MATCH1/||/MATCH2/ {print $3,","}' file


Thanks for this,But it will only Print word2 ,i i need IMAGE from MATCH1

the abv o/p will come like....

word2,word2,word2..
i need

IMAGE,word2,word2

sorry if i am not clear
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

print next line if matches a particular word..need help

Hi i need a help for making a script whch can print next line if it matches a particular word like file1 have ename Mohan eid 2008 ename Shyam eid 345 if scipt got Mohan it will print next line (eid 2008) pls help me .......:) (2 Replies)
Discussion started by: anish19
2 Replies

2. Shell Programming and Scripting

Print line if first Field matches a pattern

Hi All, I would like my code to be able to print out the whole line if 1st field has a dot in the number. Sample input and expected output given below. My AWK code is below but it can;t work, can any expert help me ? Thanks in advance. {if ($1 ~ /*\.*/) { print $0 }} Input: ... (2 Replies)
Discussion started by: Raynon
2 Replies

3. Shell Programming and Scripting

Search word in a line and print earlier pattern match

Hi All, I have almost 1000+ files and I want to search specific pattern. Looking forwarded your input. Search for: word1.word2 (Which procedure contain this word, I need procedure name in output. Expected output: procedure test1 procedure test2 procedure test3 procedure test4 ... (7 Replies)
Discussion started by: susau_79
7 Replies

4. Shell Programming and Scripting

Using awk to print line starting with particular word

Hi Geeks, Consider this line: driver=c:\folder1\folder2 The above line is contained in a variable say 'var' . I want to copy everything after 'driver=' in to another variable say var2. Please tell me how can this be done. (8 Replies)
Discussion started by: ajincoep
8 Replies

5. Shell Programming and Scripting

copy line to new file if word matches

I'm drawing blank on this. The log file I have is filled with garbage, but the important lines are ##/##/### Installation xxxxxxx So, I want to sed the line to a new file IF the word installation is in it. I tried removing none matching lines sed 's/Installation/,//!d' infile > outfile but that... (3 Replies)
Discussion started by: dba_frog
3 Replies

6. Shell Programming and Scripting

How to print last word of line

Hi, How to print last word of line? #!/bin/bash x1="This is Kiran" echo "$x1" how to print "Kiran" in new variable.i.e x2=kiran (7 Replies)
Discussion started by: kiran_j
7 Replies

7. UNIX for Dummies Questions & Answers

How to print line starts with specific word and contains specific word using sed?

Hi, I have gone through may posts and dint find exact solution for my requirement. I have file which consists below data and same file have lot of other data. <MAPPING DESCRIPTION ='' ISVALID ='YES' NAME='m_TASK_UPDATE' OBJECTVERSION ='1'> <MAPPING DESCRIPTION ='' ISVALID ='NO'... (11 Replies)
Discussion started by: tmalik79
11 Replies

8. Shell Programming and Scripting

Grep the word from pattern line and update in subsequent lines till next pattern line reached

Hi, I have got the below requirement. please suggest. I have a file like, Processing Item is: /data/ing/cfg2/abc.txt /data/ing/cfg3/bgc.txt Processing Item is: /data/cmd/for2/ght.txt /data/kernal/config.klgt.txt I want to process the above file to get the output file like, ... (5 Replies)
Discussion started by: rbalaj16
5 Replies

9. Shell Programming and Scripting

Read a File line by line and split into array word by word

Hi All, Hope you guys had a wonderful weekend I have a scenario where in which I have to read a file line by line and check for few words before redirecting to a file I have searched the forum but,either those answers dint work (perhaps because of my wrong under standing of how IFS... (6 Replies)
Discussion started by: Kingcobra
6 Replies

10. Shell Programming and Scripting

Find word in a line and output in which line the word occurs / no. of times it occurred

I have a file: file.txt, which contains the following data in it. This is a file, my name is Karl, what is this process, karl is karl junior, file is a test file, file's name is file.txt My name is not Karl, my name is Karl Joey What is your name? Do you know your name and... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies
man(5)								File Formats Manual							    man(5)

NAME
man, man.page - The man macro packages for reference pages SYNOPSIS
tbl file... | neqn | nroff -h [options] -man | ... tbl file... | neqn | nroff -h [options] -man.page | ... OPTIONS
Uses output tabs during horizontal spacing to speed output and reduce output character count. Tab settings are assumed to be every eight nominal character widths. Numbers the first generated page as N. Ignored by the man macros for nroff output. Ignored for *troff output unless -rpS is also specified. Turns on line double-spacing mode if N is greater than 0. Numbers the first generated page as N. Page numbers always print on the outside end of the page footer. Ignored by the man macros for nroff output. Sets the section number to S. Section numbers appear in output page footers as S-N (chapter-page-number). Page numbers always print on the outside end of the page footer. Starting page number defaults to "1" unless -nN or -rnN is also specified. Ignored by the man macros for nroff output. Prints crop marks. Only for use with *troff formatters. DESCRIPTION
The man macro package is used to format reference pages for unpaginated viewing, or for printing on ASCII printers. The man macro package is the default. The reference pages installed on the base system are formatted by the man and the catman commands, using the man macro package. The man.page macro package is used to format reference manual pages for paginated ASCII output. The file argument is the name of the reference page source file. The page width is 77 columns when formatted by the nroff command and the man or man.page macro packages. The output is paginated when for- matted by the nroff command and the man.page macro package, with page numbers appearing at the bottom right of each output page. Macros The following describes the macros in the man and man.page macro packages. Note that some of the macro descriptions contain information about *troff output. This is provided for completeness, only. Compaq does not supply or support any *troff formatters. Any text argument can range from zero to six words. Quotation marks (" ") can be used to include blanks in words. If text is not speci- fied, special treatment is applied to the next input line that has text to be printed. In this way, can be used to italicize a whole line or followed by to make small bold letters. A prevailing indent distance is remembered between successive indented paragraphs, and is reset to a default value upon reaching a nonin- dented paragraph. Default units for indents i are ens (an en is 1 nroff character or 1/2 em space in the current point size). Typeface and size are reset to default values before each paragraph, and after processing font and size setting macros. For *troff output only. Specifies the text string to be printed as the inside page footer. No argument, or the argument 3, specifies the text "7th Edi- tion." The argument 4 specifies the text "System III." The argument 5 specifies the text "System V." The argument 5 followed by a number argument specifies the text "System V Release number." Sets text text in boldface. If no text is specified, only the next source text line is set in boldface. Sets word1 in boldface, word2 in an italic typeface, and then alternates between these two fonts for the remain- ing words, up to six words. Blanks between words are stripped unless the string is enclosed in quotation marks (" "). Sets word1 in bold- face, word2 in a roman typeface, and then alternates between these two fonts for the remaining words, up to six words. Blanks between words are stripped unless the string is enclosed in quotation marks (" "). For *troff output only. Specifies the text string to be printed as the inside page footer. No argument, or the number 1, specifies the text "1st Carnegie-Mellon Update." The number 2 specifies the text "2nd Carnegie-Mellon Update." The number 3 specifies the text "3rd Carnegie-Mellon Update." Any whole number n above 3 specifies the text "nth Carnegie-Mellon Update." Prints the keyboard control character indicator <CTRL/character>. For example, prints as <CTRL/A>. Sets text in a constant width font until another font change is encountered. Ends an unfilled display block (started by Also ends automatic centering, if it was in effect. Ends an unfilled display block (started by and restores the left margin to the previous position. Starts an unfilled display block. Text between and is printed in a roman typeface, with `no fill' mode (no wrapping and blank lines allowed) in effect. The display block is set flush left. Starts a display block with `no fill' mode (no wrapping and blank lines allowed) in effect. The display block is shifted right .5 inch for nroff and four picas for *troff formatters. Restores default tabs. Default tabs are set to every 8 ens for nroff and to every .5 inches for *troff text formatters, starting with .5i, 1i, ... . Ends an example and restores basic text defaults and indents. Starts an example. Text between and is printed in a constant width font with `no fill' mode (no wrapping and blank lines allowed) in effect. The example is set flush left unless an indent i is specified. Units of i are ens. Sets text in a sans-serif typeface. If no text is specified, only the next source text line is set in a sans-serif typeface. Sets text in a sans-serif bold typeface. If no text is specified, only the next source text line is set in a sans-serif bold typeface. Sets text in a sans-serif italic typeface. If no text is specified, only the next source text line is set in a sans-serif italic typeface. Begins a paragraph with a hanging indent of i ens. Sets text in an italic typeface. If no text is specified, only the next source text line is set in an italic typeface. Sets a temporary indent to the length of the specified word. Reverses one line and then sets a temporary indent to the length of the specified word. Sets word1 in an italic typeface, word2 in boldface, and then alternates between these two fonts for the remaining words, up to six words. Blanks between words are stripped unless the string is enclosed in quotation marks (" "). Sets the prevailing indent to i. Then begins the indented paragraph with a hanging tag given by the next text line. If the tag does not fit, the macro places the next text on a separate line. Tag x appears in bold typeface. Sets word1 in an italic typeface, word2 in a roman typeface, and then alternates between these two fonts for the remaining words, up to six words. Blanks between words are stripped unless the string is enclosed in quotation marks (" "). Sets reference_page immediately followed by section_subsection in parentheses followed by optional punctuation, using fonts that distinguish this reference page reference from ordinary text. For example, man(5). Ends a note. Also cancels automatic centering if it was in effect. Starts a note. If no arguments are specified, the default header for the note is `Note'. If the first argument is the letter `C', all text in the note is centered, for the next 99 text lines or until the macro is called, whichever comes first. If the first argument is not `C', it becomes the header of the note, even if header2 is also specified. The header2 argument becomes the header of the note if the first argument is `C'. Sets the inter- paragraph distance to v vertical spaces. Resets the distance to the default value if v is omitted. Sets x in an italic or constant width typeface (depending on the *roff formatter type) and then reverts to the previous typeface. The optional argument y is appended to x with no space, but printed in the previous typeface. The x argument is usually a path name; y is usually punctuation. Sets x in the current typeface, sets y in an italic or constant width typeface (depending on the *roff formatter type) and appends it to x, and finally reverts to the previous typeface. The optional argument z is appended to y, but printed in the previous typeface. Spaces are removed between x, y, and z, unless quotation marks (" ") are used to enclose strings with spaces. The x argument is usually a fixed path name; y is usually a variable path name; and z is usually punctuation. Starts a block paragraph. Sets the prevailing indent to .5i for nroff and four picas for *troff text formatters. Sets the text in a roman typeface until another font change is encountered. Also ends nroff underline mode if it was in effect. Sets word1 in a roman typeface, word2 in boldface, and then alternates between these two fonts for the remaining words, up to six words. Blanks between words are stripped unless the string is enclosed in quotation marks (" "). Returns to the kth relative right shift indent level. (Restores the left margin to the position prior to the kth call). Specifying k=0 is equivalent to specifying k=1. If k is omitted, restores the left margin to the most recent previous position. When k=1 or 0, the default indent increment is restored. Sets word1 in a roman typeface, word2 in an italic typeface, and then alternates between these two fonts for the remaining words, up to six words. Blanks between words are stripped unless the string is enclosed in quotation marks (" "). Prints the return character indicator, <RETURN>. Shifts the left margin to the right (relatively) the amount of i ens. The macro calls can be nested up to nine levels. If i is not specified for the first call, the relative right shift increases .5 inch for nroff and four picas for *troff text formatters. Nested calls increment the relative indent by i ens, or by .2 inch for nroff, or by 2 picas for *troff text format- ters. Creates a section header. Sets text to be two points smaller than the current point size. If no text is specified, only the next source text line is set in the smaller point size. Creates a subsection header. Begins a new reference page and sets the page title. Also sets up headers and footers for printed output pages, sets up all defaults and traps, and calls the and macros. The title appears as a header on all pages of the formatted reference page. The n argument is the reference page name. The c argument is the primary section number or letter. The s argument is the subsection, if any. The fc argument is optional and specifies the text for the page foot center. The fl argument is optional and specifies the text for the page foot left. The hc argument is optional and specifies the text for the page head center. The o argument is optional and can be used for "origin" information; for example, "Free Software Foundation" or "X11R5." The a argument is optional and can be used to specify the machine architecture, for example "RISC." Fields n, c, and s appear together at the top of each output page (see the top of this page for an exam- ple). These fields are displayed at both the top left and right of the screen, or printed page. Fields fc and fl are in effect only with the man.page macro package, or when using a *troff formatter. Field hc appears at the top center of each output page. Field o, the "origin" label, appears under the refer- ence page name and section number, at the top left and right sides of the screen, or printed page. Field a appears under the "origin" label, or under the reference page name and section number if there is no "origin" label, at the top left and right sides of the screen, or printed page. The last five fields are optional. To skip a field, specify a pair of quotation marks ("") in the field to be skipped. Sets the prevailing indent to i. Then begins the indented paragraph with a hanging tag given by the next text line. If the tag does not fit, the macro places the next text on a separate line. For *troff output only. Specifies the text string to be printed as the inside page footer. No argument, or the number 3, specifies the text "3rd Berkeley Distribution." The number 4 specifies the text "4th Berkeley Distribution." The number 5 specifies the text "4.2 Berkeley Distribution." The number 6 specifies the text "4.3 Berkeley Distribution." The number 7 specifies the text "4.4 Berkeley Distribution." End a vertical margin bar. Starts a vertical margin bar, if `4' is specified; other- wise, the macro does nothing. Macros That Cause Line Breaks The following macros cause line breaks: De DE Ds DS EE EX HP IP PP RE SH SS TH TP Macros That Need Text Lines The following macros affect the following line of text if they are specified in the input without arguments: B BI BR G GB GL I IB IR RI RB SH SS SM Defaults Automatic hyphenation is turned on. However, last lines (ones that will cause a trap) are not hyphenated and the last and first two charac- ters of a word are not split off. Characters printed from the Special Font are artificially bolded by three units whenever the current font is `3'. The default page width is 77 columns for nroff output and 8.5 inches for output generated by *troff text formatters. For nroff output, section headers and page headers are output flush left, primary paragraphs are indented two columns, and the maximum line length is a total of 77 columns for an effective right margin of .3 inches. This allows for printing on A4 paper. Left and right page margins are 7.5 picas when *troff text formatters are used. The default page length is unlimited (unpaginated) for nroff output with the man macros, and is 66 lines long for nroff with the man.page macros. The default page length is 11 inches for output generated by *troff text formatters. The () () macro sets up the following defaults: Text is set in "noadjust" mode; the right margin is ragged. The default interparagraph distance is 1v for nroff and .5v for *troff text formatters. The basic text indent is two columns for nroff and four picas for *troff text formatters, from the left margin. The maximum text line length is 7.5 inches for nroff and 36 picas for *troff text formatters. Sets tab stops every 8 ens for nroff and every .5 inches for *troff text formatters. The basic text point size is 11 points, with line spacing set to 12 points. The basic text font is "R" (a roman typeface). Reference page headers, section headers, and subsection headers are set in a sans- serif bold typeface for *troff formatters. There are no page footers for nroff output with the man macros. Page footers are printed when using *troff formatters, and when using the man.page macros with either nroff or *troff. The default page number, when footers are printed, has the format: name(c[s])-pg where: is the () () n argument is the c[s](argument) c[s](argument) is the current page number By default, the page number prints on the right side of the page foot. When printing multiple pages, the page number is reset to "1" at the start of each new reference page. RESTRICTIONS
Predefined Registers The following registers are predefined by the man macro packages and should not be changed: Page offset and page margin Left margin indent relative to the section headers Line length including IN Page length The register `l' is predefined when you specify the *roff -rl option. Its default value is 0. The man command does not use this option. The register `n' is predefined when you specify the *roff -rn option. Its default value is 0. The man command does not use this option. The register `p' is predefined when you specify the *roff -rp option. Its default value is 0. The man command does not use this option. The register `v' is predefined when you specify the *roff -rv option. Its default value is 0. The man command does not use this option. Reserved Registers The following registers are reserved for internal use by the man and man.page macro packages: A1 d DX EX l m p p# PF pg pn v y In addition, registers beginning with the characters `)', `]', and `}' are also reserved for internal use. Registers predefined by the nroff, neqn, and tbl commands, and the *eqn and *troff text preprocessors and formatters should not be rede- fined. Predefined Strings The following strings are predefined by the man macro package and should not be changed: " if nroff, " if *troff " if nroff, " if *troff Command string to change type size to 10 points. Reserved Strings and Macros The following string and macro names are reserved for internal use by the man and man.page macro packages: ## A1 BD BK CD D HB HH ID LD NO NX P TB UF ya yn yl ys In addition, names beginning with the characters `)', `]', and `}' are also reserved for internal use. Names predefined by the nroff, neqn, and tbl commands, and the *eqn and *troff text preprocessors and formatters should not be redefined. .TH Macro Restrictions Section numbers should only be those listed in the man(1) reference page as recognized by the man command. Sections 5, 6, and the single-letter sections listed in the man(1) reference page normally do not have subsections, so none should be spec- ified. Subsections ".z" and ".Z" are not valid and should never be used. For nroff output, keep the size of the reference page name, including its section and subsection, to a maximum of 38 characters to prevent overprinting in the reference page header. Similarly, restrict the size of the o and a fields to a maximum of 38 characters. If the hc field is used, reduce the size of the name, section, and subsection fields by the size of the hc field + 1. The maximum sizes for the reference page name, o and a fields, are much shorter if the reference page is formatted with a *troff formatter. The NAME Section The catman command assumes the NAME section of a reference page has the following format: name[, name, name ...] - explanatory text There should be at least one space after any comma and only one space following the "hyphen" (-). A "backslash hyphen" (-) may also be used to produce a longer dash. Avoid using macros or other markup to code information in the NAME section. The explanatory text should be brief. The catman command combines information in the NAME section with parameters of the () () macro to create an entry in a database searched by the apropos, man, and whatis commands. PORTABILITY CONSIDERATIONS
The Tru64 UNIX man macro packages contain extensions and enhancements borrowed from other macro packages. If you need to write portable reference pages, you should not use the following macros: AT CM CT CW De Ds EE EX G GB GL I1 I2 LP MS NE NT PN Pn R RN UC UF The macro is obsolete, but is provided for backward compatibility with other vendors. The () () macro permits the use of the percent (%) character in any of its fields. The presence of the percent character may cause problems for other implementations of this macro. The width of the nroff output is 77 columns, with a 2-column indent, for an effective maximum line length of 75 columns. On other systems, the width of the nroff output may be only 65 columns, with a 5-column indent, for an effective maximum line length of 60 columns. Avoid creating tables and no-fill text that require the full 75 columns available. Plan for a maximum line length of 60 columns, instead. FILES
The man macro package interface The primary man macros package Old BSD V6 man macros for nroff Old BSD V6 man macros for troff The man.page macro package interface The primary man.page macros package SEE ALSO
Commands: checkeq(1), man(1), neqn(1), nroff(1), tbl(1), catman(8) Files: rsml(5) ()
All times are GMT -4. The time now is 01:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy