Sponsored Content
Top Forums UNIX for Dummies Questions & Answers how to find a word in a file that appears next to a given keyword Post 302450199 by mwrg on Thursday 2nd of September 2010 01:59:48 AM
Old 09-02-2010
how to find a word in a file that appears next to a given keyword

Hi Experts,

I have a file which contains some text. i need to print the word next to a given keyword. Please help.

Ex: test.txt
Code:
 
=====================
NEXT HOST
=====================
 AEADBAS001
access-list 1 permit xxxxxxxxxxxxxx
ip access-list extended BLA_Outgoing_Filter
access-list 1 permit xxxxxxxxxxxxxx
access-list 2 permit xxxxxxxxxxxxxx

If i use the keyword "extended" it should return BLA_Outgoing_Filter

Moderator's Comments:
Mod Comment Having 25 posts you should be familiar using code tags.

Last edited by zaxxon; 09-02-2010 at 07:53 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find a word in a file, and change a word beneath it ??

Hi all, I have a file with lines written somewhat like this. aaaa ccc aa linux browse = no xssxw cdcedc dcsdcd csdw police dwed dwd browse = no cdecec (2 Replies)
Discussion started by: vikas027
2 Replies

2. Shell Programming and Scripting

Replace only if the keyword is the first word in every line

How do I replace only if the keyword is at the begining of a line? Code: -- a = “This is a print statement” print a -- What if I want to replace print by #print only in the second line i.e only if the line starts with that keyword. Please help me out. I'm new to SED. -----Post... (5 Replies)
Discussion started by: alexzubin
5 Replies

3. Shell Programming and Scripting

find keyword from file and search in another file

hi dudes; this is my file.txt:20101228-180436_Down a 1 b 2 ... 20101228-190436_Rollback a 1 40 e 3 20 ... 20101228-180436_Down c 2 f 2 c 1 ... and i have a down.txt:a 1 aa 2 30 bb 1 40 b 2 ab 3 10 c 3 cd 4 50 ac 2 20 c 3 ad 1 0 (2 Replies)
Discussion started by: gc_sw
2 Replies

4. UNIX for Dummies Questions & Answers

Find EXACT word in files, just the word: no prefix, no suffix, no 'similar', just the word

I have a file that has the words I want to find in other files (but lets say I just want to find my words in a single file). Those words are IDs, so if my word is ZZZ4, outputs like aaZZZ4, ZZZ4bb, aaZZZ4bb, ZZ4, ZZZ, ZyZ4, ZZZ4.8 (or anything like that) WON'T BE USEFUL. I need the whole word... (6 Replies)
Discussion started by: chicchan
6 Replies

5. Shell Programming and Scripting

How to get the next word which falls just after a keyword?

Hi friends, i just want to know the command though which i can get the next word which comes just after a particluar keyword. For example: suppose text.out is file which contains a pl/sql procedure . i want to find out the word which falls just after the "table1" keyword. Thank... (7 Replies)
Discussion started by: neelmani
7 Replies

6. Shell Programming and Scripting

How to catch a two word keyword which may contain a new line(may include spaces or tab) in it?

How to catch a two word keyword which may contain a new line(may include spaces or tab) in it. for example there is a file a.txt. $more a.txt create view as (select from ......... .......... ( select .... ( select ...... .. select only no ((( number ( select end (12 Replies)
Discussion started by: neelmani
12 Replies

7. Shell Programming and Scripting

Search for a Keyword in file and replace another keyword or add at the end of line

Hi I want to implement something like this: if( keyword1 exists) then check if(keyword2 exists in the same line) then replace keyword 2 with New_Keyword else Add New_Keyword at the end of line end if eg: Check for Keyword JUNGLE and add/replace... (7 Replies)
Discussion started by: dashing201
7 Replies

8. Shell Programming and Scripting

Need to extract the word after a particular keyword throughout the file..

Hi Everyone, Need help in extracting the hostname from the below output. Expected output: DS-TESTB-GDS-1.TEST.ABC.COM DS-TESTB-GDS-2.TEST.ABC.COM .... ... /tmp $ cat -n /tmp/patchreport 1 /usr/bin/perl /admin/bin/patch/applyPatches.pl --apply_patches... (4 Replies)
Discussion started by: thiyagoo
4 Replies

9. Shell Programming and Scripting

Find all lines in file such that each word on that line appears in at least n lines of the file

I have a file where every line includes four expressions with a caret in the middle (plus some other "words" or fields, always separated by spaces). I would like to extract from this file, all those lines such that each of the four expressions containing a caret appears in at least four different... (9 Replies)
Discussion started by: uncleMonty
9 Replies

10. UNIX for Beginners Questions & Answers

How to align/sort the column pairs of an csv file, based on keyword word specified in another file?

I have a csv file as shown below, xop_thy 80 avr_njk 50 str_nyu 60 avr_irt 70 str_nhj 60 avr_ngt 50 str_tgt 80 xop_nmg 50 xop_nth 40 cyv_gty 40 cop_thl 40 vir_tyk 80 vir_plo 20 vir_thk 40 ijk_yuc 70 cop_thy 70 ijk_yuc 80 irt_hgt 80 I need to align/sort the csv file based... (7 Replies)
Discussion started by: dineshkumarsrk
7 Replies
PTS_SETFIELDS(1)					       AFS Command Reference						  PTS_SETFIELDS(1)

NAME
pts_setfields - Sets privacy flags or quota for a Protection Database entry SYNOPSIS
pts setfields -nameorid <user or group name or id>+ [-access <set privacy flags>] [-groupquota <set limit on group creation>] [-cell <cell name>] [-noauth] [-localauth] [-force] [-help] pts setf -na <user or group name or id>+ [-a <set privacy flags>] [-g <set limit on group creation>] [-c <cell name>] [-no] [-l] [-f] [-h] DESCRIPTION
The pts setfields command sets the group-creation quota, the privacy flags, or both, associated with each user, machine, or group entry specified by the -nameorid argument. To examine the current quota and privacy flags, use the pts examine command. CAUTIONS
Changing a machine or group's group-creation quota is allowed, but not recommended. The concept is meaningless for machines and groups, because it is impossible to authenticate as a group or machine. Similarly, some privacy flag settings do not have a sensible interpretation. OPTIONS specifies the appropriate settings. OPTIONS
-nameorid <user or group name or id>+ Specifies the name or AFS UID of each user, the IP address (complete or wildcard-style) of each machine, or the name or AFS GID of each machine for which to set privacy flags or group-creation quota. It is acceptable to mix users, machines, and groups on the same command line, as well as names (IP addresses for machines) and IDs. Precede the GID of each group with a hyphen to indicate that it is negative. -access <privacy flags> Specifies the privacy flags to apply to each entry. Provide a string of five characters, one for each of the permissions. If this option is omitted, the current setting remains unchanged. Set each flag to achieve the desired combination of permissions. If the following list does not mention a certain setting, it is not acceptable. For further discussion of the privacy flags, see pts_examine(1). o The first flag determines who can use the pts examine command to display information from a user, machine or group's Protection Database entry. o Set it to lowercase "s" to permit the members of the system:administrators group to display a user, machine, or group entry, the associated user to display a user entry, and the owner or members of a group to display the group entry. o Set it to uppercase "S" to permit anyone who can access the cell's database server machines to display a user, machine, or group entry. o The second flag determines who can use the pts listowned command to list the groups that a user or group owns. o Set it to the hyphen ("-") to permit the members of the system:administrators group and a user to list the groups he or she owns, or to permit the members of the system:administrators group and a group's owner to list the groups that a group owns. o Set it to uppercase letter "O" to permit anyone who can access the cell's database server machines to list the groups owned by a machine or group entry. o The third flag determines who can use the pts membership command to list the groups to which a user or machine belongs, or the users and machines that belong to a group. o Set it to the hyphen ("-") to permit the members of the system:administrators group and a user to list the groups he or she belongs to, to permit the members of the system:administrators group to list the groups a machine belongs to, or to permit the members of the system:administrators group and a group's owner to list the users and machines that belong to it. o Set it to lowercase "m" to permit members of a group to list the other members. (For user and machine entries, this setting is equivalent to the hyphen.) o Set it to uppercase "M" to permit anyone who can access the cell's database server machines to list membership information for a user, machine or group. o The fourth flag determines who can use the pts adduser command to add users and machines as members of a group. This flag has no sensible interpretation for user and machine entries, but must be set nonetheless, preferably to the hyphen. o Set it to the hyphen ("-") to permit the members of the system:administrators group and the owner of the group to add members. o Set it to lowercase "a" to permit members of a group to add other members. o Set it to uppercase "A" to permit anyone who can access the cell's database server machines to add members to a group. o The fifth flag determines who can use the pts removeuser command to remove users and machines from membership in a group. This flag has no sensible interpretation for user and machine entries, but must be set nonetheless, preferably to the hyphen. o Set it to the hyphen ("-") to permit the members of the system:administrators group and the owner of the group to remove members. o Set it to lowercase "r" to permit members of a group to remove other members. -groupquota <group creation quota> Specifies the number of additional groups a user can create (it does not matter how many he or she has created already). Do not include this argument for a group or machine entry. -cell <cell name> Names the cell in which to run the command. For more details, see pts(1). -force Enables the command to continue executing as far as possible when errors or other problems occur, rather than halting execution at the first error. -help Prints the online help for this command. All other valid options are ignored. -localauth Constructs a server ticket using a key from the local /etc/openafs/server/KeyFile file. Do not combine this flag with the -cell or -noauth options. For more details, see pts(1). -noauth Assigns the unprivileged identity anonymous to the issuer. For more details, see pts(1). EXAMPLES
The following example changes the privacy flags on the group "operators", retaining the default values of the first, second and third flags, but setting the fourth and fifth flags to enable the group's members to add and remove other members. % pts setfields -nameorid operators -access S-Mar The following example changes the privacy flags and sets group quota on the user entry "admin". It retains the default values of the first, fourth, and fifth flags, but sets the second and third flags, to enable anyone to list the groups that "admin" owns and belongs to. Users authenticated as "admin" can create an additional 50 groups. % pts setfields -nameorid admin -access SOM-- -groupquota 50 PRIVILEGE REQUIRED
To edit group entries or set the privacy flags on any type of entry, the issuer must own the entry or belong to the system:administrators group. To set group-creation quota on a user entry, the issuer must belong to the system:administrators group. SEE ALSO
pts(1), pts_adduser(1), pts_examine(1), pts_listowned(1), pts_membership(1), pts_removeuser(1) COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved. This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell. OpenAFS 2014-04-08 PTS_SETFIELDS(1)
All times are GMT -4. The time now is 06:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy