Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Awk print all lines on match? Post 302511809 by ctsgnb on Thursday 7th of April 2011 03:01:14 PM
Old 04-07-2011
Print all line containing 'toto' in file called 'tst' :

Code:
# cat tst
zroezp toto rueziar
roez tutu uezir
roezp toto reziar
zroezp titi rueiar
roezp toto ruezar
roezp tata rueziar
zroezp titi rziar
zroep toto rzir
zrezp tata ruziar
zezp toto rziar
roezp toto rueziar

Code:
# awk '/toto/' tst
zroezp toto rueziar
roezp toto reziar
roezp toto ruezar
zroep toto rzir
zezp toto rziar
roezp toto rueziar

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to print lines based on string match on another line and condition

Hi folks, I have a text file that I need to parse, and I cant figure it out. The source is a report breaking down softwares from various companies with some basic info about them (see source snippet below). Ultimately what I want is an excel sheet with only Adobe and Microsoft software name and... (5 Replies)
Discussion started by: rowie718
5 Replies

2. Shell Programming and Scripting

how to print all lines from a second match

I am trying to parse iostat output for io issues.. I want to print all lines including second occurance of 'extended' till EOF(end of file). Can we do that using awk or sed one liners or do we need a script for it? (1 Reply)
Discussion started by: kchinnam
1 Replies

3. Shell Programming and Scripting

Print lines before and after pattern match

I am using Solaris, I want to print 3 lines before pattern match pattern 5 lines after pattern match Pattern is abcd to be searched in a.txt. Looking for the solution in sed/awk/perl. Thanks .. Input File a.txt: ================= 1 2 3 abcd 4 5 6 7 8 (7 Replies)
Discussion started by: manuswami
7 Replies

4. UNIX for Dummies Questions & Answers

awk display the match and 2 lines after the match is found.

Hello, can someone help me how to find a word and 2 lines after it and then send the output to another file. For example, here is myfile1.txt. I want to search for "Error" and 2 lines below it and send it to myfile2.txt I tried with grep -A but it's not supported on my system. I tried with awk,... (4 Replies)
Discussion started by: eurouno
4 Replies

5. Shell Programming and Scripting

Print all lines before first match

Hi, I have this file. close block3c block3b block3a open close block2b block2a open close block1a open and I need : open block3a block3b block3c close (1 Reply)
Discussion started by: lasserfox
1 Replies

6. Shell Programming and Scripting

awk print pattern match line and following lines

Data: Pattern Data Data Data Data Data Data Data Data Data ... With awk, how do I print the pattern matching line, then the subsequent lines following the pattern matching line. Varying number of lines following the pattern matching line. (9 Replies)
Discussion started by: dmesserly
9 Replies

7. Shell Programming and Scripting

awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column

Hi, My input files is like this axis1 0 1 10 axis2 0 1 5 axis1 1 2 -4 axis2 2 3 -3 axis1 3 4 5 axis2 3 4 -1 axis1 4 5 -6 axis2 4 5 1 Now, these are my following tasks 1. Print a first column for every two rows that has the same value followed by a string. 2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

8. UNIX for Dummies Questions & Answers

awk - (URGENT!) Print lines sort and move lines if match found

URGENT HELP IS NEEDED!! I am looking to move matching lines (01 - 07) from File1 and 77 tab the matching string from File2, to File3.txt. I am almost done but - Currently, script is not printing lines to File3.txt in order. - Also the matching lines are not moving out of File1.txt ... (1 Reply)
Discussion started by: High-T
1 Replies

9. Shell Programming and Scripting

Match the value & print lines from the match

Hello, I have a file contains two columns. I need to print the lines after “xxx” so i'm trying to match "xxx" & cut the lines after that. I'm trying with the grep & cut command, if there any simple way to extract this please help me. Sample file : name id AAA 123 AAB 124 AAC 125... (4 Replies)
Discussion started by: Shenbaga.d
4 Replies

10. Shell Programming and Scripting

awk to print match or non-match and select fields/patterns for non-matches

In the awk below I am trying to output those lines that Match between file1 and file2, those Missing in file1, and those missing in file2. Using each $1,$2,$4,$5 value as a key to match on, that is if those 4 fields are found in both files the match, but if those 4 fields are not found then missing... (0 Replies)
Discussion started by: cmccabe
0 Replies
nis_groups(3NSL)				       Networking Services Library Functions					  nis_groups(3NSL)

NAME
nis_groups, nis_ismember, nis_addmember, nis_removemember, nis_creategroup, nis_destroygroup, nis_verifygroup, nis_print_group_entry - NIS+ group manipulation functions SYNOPSIS
cc [ flag ... ] file ... -lnsl [ library ... ] #include <rpcsvc/nis.h> bool_t nis_ismember(nis_name principal, nis_name group); nis_error nis_addmember(nis_name member, nis_name group); nis_error nis_removemember(nis_name member, nis_name group); nis_error nis_creategroup(nis_name group, uint_t flags); nis_error nis_destroygroup(nis_name group); void nis_print_group_entry(nis_name group); nis_error nis_verifygroup(nis_name group); DESCRIPTION
These functions manipulate NIS+ groups. They are used by NIS+ clients and servers, and are the interfaces to the group authorization object. The names of NIS+ groups are syntactically similar to names of NIS+ objects but they occupy a separate namespace. A group named "a.b.c.d." is represented by a NIS+ group object named "a.groups_dir.b.c.d."; the functions described here all expect the name of the group, not the name of the corresponding group object. There are three types of group members: o An explicit member is just a NIS+ principal-name, for example "wickedwitch.west.oz." o An implicit ("domain") member, written "*.west.oz.", means that all principals in the given domain belong to this member. No other forms of wildcarding are allowed: "wickedwitch.*.oz." is invalid, as is "wickedwitch.west.*.". Note that principals in subdomains of the given domain are not included. o A recursive ("group") member, written "@cowards.oz.", refers to another group. All principals that belong to that group are considered to belong here. Any member may be made negative by prefixing it with a minus sign ('-'). A group may thus contain explicit, implicit, recursive, negative explicit, negative implicit, and negative recursive members. A principal is considered to belong to a group if it belongs to at least one non-negative group member of the group and belongs to no nega- tive group members. The nis_ismember() function returns TRUE if it can establish that principal belongs to group; otherwise it returns FALSE. The nis_addmember() and nis_removemember() functions add or remove a member. They do not check whether the member is valid. The user must have read and modify rights for the group in question. The nis_creategroup() and nis_destroygroup() functions create and destroy group objects. The user must have create or destroy rights, respectively, for the groups_dir directory in the appropriate domain. The parameter flags to nis_creategroup() is currently unused and should be set to zero. The nis_print_group_entry() function lists a group's members on the standard output. The nis_verifygroup() function returns NIS_SUCCESS if the given group exists, otherwise it returns an error code. These functions only accept fully-qualified NIS+ names. A group is represented by a NIS+ object with a variant part that is defined in the group_obj structure. See nis_objects(3NSL). It con- tains the following fields: uint_t gr_flags; /* Interpretation Flags (currently unused) */ struct { uint_t gr_members_len; nis_name *gr_members_val; } gr_members; /* Array of members */ NIS+ servers and clients maintain a local cache of expanded groups to enhance their performance when checking for group membership. Should the membership of a group change, servers and clients with that group cached will not see the change until either the group cache has expired or it is explicitly flushed. A server's cache may be flushed programmatically by calling the nis_servstate() function with tag TAG_GCACHE and a value of 1. There are currently no known methods for nis_ismember(), nis_print_group_entry(), and nis_verifygroup() to get their answers from only the master server. EXAMPLES
Example 1: Simple Memberships Given a group sadsouls.oz. with members tinman.oz., lion.oz., and scarecrow.oz., the function call bool_var = nis_ismember("lion.oz.", "sadsouls.oz."); will return 1 (TRUE) and the function call bool_var = nis_ismember("toto.oz.", "sadsouls.oz."); will return 0 (FALSE). Example 2: Implicit Memberships Given a group baddies.oz., with members wickedwitch.west.oz. and *.monkeys.west.oz., the function call bool_var = nis_ismem- ber("hogan.monkeys.west.oz.", "baddies.oz."); will return 1 (TRUE) because any principal from the monkeys.west.oz. domain belongs to the implicit group *.monkeys.west.oz., but the function call bool_var = nis_ismember("hogan.big.monkeys.west.oz.", "baddies.oz."); will return 0 (FALSE). Example 3: Recursive Memberships Given a group goodandbad.oz., with members toto.kansas, @sadsouls.oz., and @baddies.oz., and the groups sadsouls.oz. and baddies.oz. defined above, the function call bool_var = nis_ismember("wickedwitch.west.oz.", "goodandbad.oz."); will return 1 (TRUE), because wickedwitch.west.oz. is a member of the baddies.oz. group which is recursively included in the goodand- bad.oz. group. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
nisgrpadm(1), nis_objects(3NSL), attributes(5) NOTES
NIS+ might not be supported in future releases of the SolarisTM Operating Environment. Tools to aid the migration from NIS+ to LDAP are available in the Solaris 9 operating environment. For more information, visit http://www.sun.com/directory/nisplus/transition.html. SunOS 5.10 18 Dec 2001 nis_groups(3NSL)
All times are GMT -4. The time now is 09:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy