Sponsored Content
Operating Systems AIX Print nth previous line after match Post 302970046 by Don Cragun on Friday 1st of April 2016 12:42:26 AM
Old 04-01-2016
Is this a homework assignment? Homework and coursework questions can only be posted in the Homework & Coursework forum under special homework rules.

If you did post homework in this forum, please review the guidelines for posting homework and repost.

Otherwise, please:
  1. explain why you need to do this,
  2. show us what you have tried to solved this on your own,
  3. show us sample input and corresponding desired output, and
  4. tell us what operating system and shell you're using.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

return previous line for pattern match

Hi, Need some idea on file processing, I have file like below, Processing al sources ... ...No value found : CHECK. Completed comparing all sources. Comparing schedulers... Processing al targets ... ...No value found : From above I need to extract the line where "No value... (4 Replies)
Discussion started by: braindrain
4 Replies

2. Shell Programming and Scripting

Getting filename for Nth line pattern match

Hi, I have many scripts in particular directory. And few of the scripts have exit 0 in second line. Now i wanted to list out the scripts name which has the exit 0 in its second line I tried many options , but i can not get the filename along with the nth line pattern match :mad:. Can anyone... (14 Replies)
Discussion started by: puni
14 Replies

3. Shell Programming and Scripting

search pattern and replace x-y characters in nth line after every match

Hi, I am looking for any script which can do the following. have to read a pattern from fileA and copy it to fileB. fileA: ... ... Header ... ... ..p1 ... ... fileB: .... .... Header (3 Replies)
Discussion started by: anilvk
3 Replies

4. Shell Programming and Scripting

Delete line with match and previous line quoting/escaping problem

Hi folks, I've list of LDAP records in this format: cat cmmac.export.tmp2 dn: deviceId=0a92746a54tbmd34b05758900131136a506,ou=devices,ou=customer,ou=nl,o=upc cmmac: 00:13:11:36:a5:06 dn: deviceId=0a92746a62pbms4662299650015961cfa23,ou=devices,ou=customer,ou=nl,o=upc cmmac:... (4 Replies)
Discussion started by: tomas.polak
4 Replies

5. Shell Programming and Scripting

Print every nth line

Dear all, How to print every nth line. File like this: File input: 1 1 1 1 1 1 2 2 2 3 3 3 3 3 3 (3 Replies)
Discussion started by: attila
3 Replies

6. UNIX for Dummies Questions & Answers

Printing nth and n+1th line after a pattern match

Hi , I want to print the nth and n+1 lines from a file once it gets a pattern match. For eg: aaa bbb ccc ddd gh jjjj If I find a match for bbb then I need to print bbb as well as 3rd and 4th line from the match.. Please help..Is it possible to get a command using sed :) (6 Replies)
Discussion started by: saj
6 Replies

7. Shell Programming and Scripting

Print nth line in a file

Bash/Oracle Linux 6.4 A basic requirement. How can I get nth line of a file printed ? Can I use grep in this case ? Example: In the below file, 12th line is "Kernel parameter check passed for rmem_max" . I just want the 12 line to be printed. # cat sometext.txt Kernel version check... (2 Replies)
Discussion started by: John K
2 Replies

8. Shell Programming and Scripting

How to display when nth line match a pattern?

Hi All, I have sample of listing as following Database 2 entry: Database alias = PXRES Database name = PXRES Local database directory = /db2/data1/db2phnx Database release level = d.00 Comment ... (3 Replies)
Discussion started by: ckwan
3 Replies

9. Shell Programming and Scripting

How to delete the previous line after pattern match?

Team, I am writing a shell script to perform few health checks of the system, where I need to delete the previous line in the text file after pattern match using sed (or) awk. Could you please help me out on this? For example, <td> <td style=color:green align=center> </td> </tr>... (6 Replies)
Discussion started by: Nagaraj R
6 Replies

10. UNIX for Beginners Questions & Answers

awk or sed to print the character from the previous line after the regexp match

Hi All, I need to print the characters in the previous line just before the regular expression match Please have a look at the input file as attached I need to match the regular expression ^ with the character of the previous like and also the pin numbers and the output file should be like... (6 Replies)
Discussion started by: kshitij
6 Replies
Mojo::DOM::CSS(3pm)					User Contributed Perl Documentation				       Mojo::DOM::CSS(3pm)

NAME
Mojo::DOM::CSS - CSS3 selector engine SYNOPSIS
use Mojo::DOM::CSS; # Select elements from DOM tree my $css = Mojo::DOM::CSS->new(tree => $tree); my $elements = $css->select('h1, h2, h3'); DESCRIPTION
Mojo::DOM::CSS is the CSS3 selector engine used by Mojo::DOM. SELECTORS
All CSS3 selectors that make sense for a standalone parser are supported. "*" Any element. my $all = $css->select('*'); "E" An element of type "E". my $title = $css->select('title'); "E[foo]" An "E" element with a "foo" attribute. my $links = $css->select('a[href]'); "E[foo="bar"]" An "E" element whose "foo" attribute value is exactly equal to "bar". my $fields = $css->select('input[name="foo"]'); "E[foo~="bar"]" An "E" element whose "foo" attribute value is a list of whitespace-separated values, one of which is exactly equal to "bar". my $fields = $css->select('input[name~="foo"]'); "E[foo^="bar"]" An "E" element whose "foo" attribute value begins exactly with the string "bar". my $fields = $css->select('input[name^="f"]'); "E[foo$="bar"]" An "E" element whose "foo" attribute value ends exactly with the string "bar". my $fields = $css->select('input[name$="o"]'); "E[foo*="bar"]" An "E" element whose "foo" attribute value contains the substring "bar". my $fields = $css->select('input[name*="fo"]'); "E:root" An "E" element, root of the document. my $root = $css->select(':root'); "E:checked" A user interface element "E" which is checked (for instance a radio-button or checkbox). my $input = $css->select(':checked'); "E:empty" An "E" element that has no children (including text nodes). my $empty = $css->select(':empty'); "E:nth-child(n)" An "E" element, the "n-th" child of its parent. my $third = $css->select('div:nth-child(3)'); my $odd = $css->select('div:nth-child(odd)'); my $even = $css->select('div:nth-child(even)'); my $top3 = $css->select('div:nth-child(-n+3)'); "E:nth-last-child(n)" An "E" element, the "n-th" child of its parent, counting from the last one. my $third = $css->select('div:nth-last-child(3)'); my $odd = $css->select('div:nth-last-child(odd)'); my $even = $css->select('div:nth-last-child(even)'); my $bottom3 = $css->select('div:nth-last-child(-n+3)'); "E:nth-of-type(n)" An "E" element, the "n-th" sibling of its type. my $third = $css->select('div:nth-of-type(3)'); my $odd = $css->select('div:nth-of-type(odd)'); my $even = $css->select('div:nth-of-type(even)'); my $top3 = $css->select('div:nth-of-type(-n+3)'); "E:nth-last-of-type(n)" An "E" element, the "n-th" sibling of its type, counting from the last one. my $third = $css->select('div:nth-last-of-type(3)'); my $odd = $css->select('div:nth-last-of-type(odd)'); my $even = $css->select('div:nth-last-of-type(even)'); my $bottom3 = $css->select('div:nth-last-of-type(-n+3)'); "E:first-child" An "E" element, first child of its parent. my $first = $css->select('div p:first-child'); "E:last-child" An "E" element, last child of its parent. my $last = $css->select('div p:last-child'); "E:first-of-type" An "E" element, first sibling of its type. my $first = $css->select('div p:first-of-type'); "E:last-of-type" An "E" element, last sibling of its type. my $last = $css->select('div p:last-of-type'); "E:only-child" An "E" element, only child of its parent. my $lonely = $css->select('div p:only-child'); "E:only-of-type" An "E" element, only sibling of its type. my $lonely = $css->select('div p:only-of-type'); "E.warning" my $warning = $css->select('div.warning'); An "E" element whose class is "warning". "E#myid" my $foo = $css->select('div#foo'); An "E" element with "ID" equal to "myid". E:not(s) An "E" element that does not match simple selector "s". my $others = $css->select('div p:not(:first-child)'); "E F" An "F" element descendant of an "E" element. my $headlines = $css->select('div h1'); "E > F" An "F" element child of an "E" element. my $headlines = $css->select('html > body > div > h1'); "E + F" An "F" element immediately preceded by an "E" element. my $second = $css->select('h1 + h2'); "E ~ F" An "F" element preceded by an "E" element. my $second = $css->select('h1 ~ h2'); "E, F, G" Elements of type "E", "F" and "G". my $headlines = $css->select('h1, h2, h3'); "E[foo=bar][bar=baz]" An "E" element whose attributes match all following attribute selectors. my $links = $css->select('a[foo^="b"][foo$="ar"]'); ATTRIBUTES
Mojo::DOM::CSS implements the following attributes. "tree" my $tree = $css->tree; $css = $css->tree(['root', [qw(text lalala)]]); Document Object Model. METHODS
Mojo::DOM::CSS inherits all methods from Mojo::Base and implements the following new ones. "select" my $results = $css->select('head > title'); Run CSS3 selector against "tree". SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo::DOM::CSS(3pm)
All times are GMT -4. The time now is 09:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy