Sponsored Content
Top Forums Shell Programming and Scripting Search a String and display only word. Post 302443129 by indrajit_u on Friday 6th of August 2010 08:10:36 PM
Old 08-06-2010
Question Search a String and display only word.

Hello Gurus,

Apologies if this Q has been repeated but i was not able to find it Smilie

I have an input file:
-------------------------------
Replace DB.Employee
as
select
column1
column2
from DB_T.Emp
and DB.Test
and
DB.Dept
and
DB_T.Ter;

------------------------

I want whole word that matches "DB." or "DB_T." i.e my output file should look like:

---------------------------
DB.Employee
DB_T.Emp
DB.Test
DB.Dept
DB_T.Ter
---------------------------
Grep is displaying the whole line but i just want the word.
Thank you in advance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to check a string conating a search word or not ...

Hi fiends, I need some help. i have a var called fname="req_detail_TAM.dat" and is have a search string var as tmp="TAM". Now my requirement is i need to check whether a "fname" is contains "search str" or not. if search string is part of the filename, then i need to store value 1 in a... (2 Replies)
Discussion started by: manu.vmr
2 Replies

2. Shell Programming and Scripting

Search for string and display those NOT found

In my script I read a input file and search all the files in a directory and it's sub-directories for that string using: find . -type f -print | xargs grep $var1 This just displays all the lines the string was found on. Too much data. What I need is to store in a file one time those... (17 Replies)
Discussion started by: John Rihn
17 Replies

3. UNIX for Advanced & Expert Users

Parsing String, Search then display rows

Get occurence of "open" considering duplicates(get the last open). Once you are pointing to the last open count 2 rows to get the correct data. Every begin and end statement, there is a "close" and "open". There can be many "close" and "open" within the begin and end statement but we are... (9 Replies)
Discussion started by: buddyme
9 Replies

4. Shell Programming and Scripting

search a word and print specific string using awk

Hi, I have list of directory paths in a variable and i want to delete those dirs and if dir does not exist then search that string and get the correct path from xml file after that delete the correct directory. i tried to use grep and it prints the entire line from the search.once i get the entire... (7 Replies)
Discussion started by: dragon.1431
7 Replies

5. Shell Programming and Scripting

search-word-print-specific-string

Hi, Our input xml looks like: <doc> <str name="account_id">1111</str> <str name="prd_id">DHEP155EK</str> </doc> - <doc> <str name="account_id">6666</str> <str name="prd_id">394531662</str> </doc> - <doc> <str name="account_id">6666</str> <str... (1 Reply)
Discussion started by: Jassz
1 Replies

6. Shell Programming and Scripting

Search string in unix and print whole matching word

Hi I have requirement to search string starting with specific characters and print whole matching word in that string. example mystr="ATTRIBUTE NAME="Event Name" VALUE="Execute"" I want to search by passing "NAME=" and result should be NAME="Event Name". i am using below command but... (3 Replies)
Discussion started by: tmalik79
3 Replies

7. Shell Programming and Scripting

Grep word after last occurance of string and display next few lines

Hi, I wanted to grep string "ERROR" and "WORNING" after last occurrence of String "Starting" only and wanted to display two lines after searched ERROR and WORNING string and one line before. I have following cronjob log file "errorlog" file and I have written the code for same in Unix as below... (17 Replies)
Discussion started by: nes
17 Replies

8. Shell Programming and Scripting

Search and replace the string with new word using xml tags

Hi All i need to replace the url1 inside <remote> tag in below xml in first instance and in the second instance with url2. any help appreciated <locations> <hudson.scm.SubversionSCM_-ModuleLocation> <remote>https://svn2015.com/svn/repos/internalshard</remote> ... (4 Replies)
Discussion started by: madankumar.t@hp
4 Replies

9. UNIX for Beginners Questions & Answers

Search a string and display its location on the entire string and make a text file

I want to search a small string in a large string and find the locations of the string. For this I used grep "string" -ob <file name where the large string is stored>. Now this gives me the locations of that string. Now how do I store these locations in a text file. Please use CODE tags as... (7 Replies)
Discussion started by: ANKIT ROY
7 Replies

10. Shell Programming and Scripting

Search string in multiple files and display column wise

I have 3 files. Each of those files have the same number of records, however certain records have different values. I would like to grep the field in ALL 3 files and display the output with only the differences in column wise and if possible line number File1 Name = Joe Age = 33... (3 Replies)
Discussion started by: sidnow
3 Replies
replcon(1)						      General Commands Manual							replcon(1)

NAME
replcon - SELinux file context replacement tool SYNOPSIS
replcon NEW_CONTEXT DIR [OPTIONS] [EXPRESSION] DESCRIPTION
replcon allows the user to find and replace file contexts. Replacements can be filtered by object class as described below. REQUIRED ARGUMENTS
NEW_CONTEXT The replacement context as expressed as a partial context, described below. DIR Initial directory to begin searching. The tool will recurse into any subdirectories, so be sure there are no circular mounts within it. EXPRESSION
The following options allow the user to specify which files to find. A file must meet all specified criteria for its context to be replaced. If no expression is provided, all files' contexts are replaced. -t TYPE, --type=TYPE Search for files with a context containing the type TYPE. -u USER, --user=USER Search for files with a context containing the user USER. -r ROLE, --role=ROLE Search for files with a context containing the role ROLE. -m RANGE, --mls-range=RANGE Search for files with a context with the MLS range of RANGE. Note that replcon ignores the SELinux translation library, if present. In addition, this flag is ignored if DIR has no MLS information. --context=CONTEXT Search for files matching this partial context. This flag overrides -t, -u, -r, and -m. -p PATH, --path=PATH Search for files which include PATH. -c CLASS, --class=CLASS Search only files of object class CLASS. OPTIONS
-v, --verbose Display context info during replacement. -h, --help Print help information and exit. -V, --version Print version information and exit. PARTIAL CONTEXT
The --context flag and NEW_CONTEXT argument specify a partial context, which is a a colon separated list of user, role, and type. If the system supports MLS, the context may have a fourth field that gives the range. With --context if a field is not specified or is the lit- eral asterisk, then the query will always match the field. With NEW_CONTEXT if a field is not specified or is the literal asterisk, then that portion of the context will not be modified. OBJECT CLASSES
Valid object class strings are block, char, dir, fifo, file, link, or sock. NOTE
The replcon utility always operates on "raw" SELinux file contexts. If the system has an installed translation library (i.e., libsetrans), those translations are ignored in favor of reading the original contexts from the filesystem. EXAMPLES
replcon ::type_t: . Replace every context's type in the current directory with type_t. The user and role portion remain unchanged. replcon -u user_u *:role_r:* . Replace every context's role with user user_u in the current directory with role_r. The user and type portion remain unchanged. replcon --context ::type_t:s0 :::s0:c0 /tmp Replace every context with type type_t and MLS range s0 in /tmp with MLS range s0:c0. AUTHOR
This manual page was written by Jeremy A. Mowery <jmowery@tresys.com>. COPYRIGHT
Copyright(C) 2003-2007 Tresys Technology, LLC BUGS
Please report bugs via an email to setools-bugs@tresys.com. SEE ALSO
findcon(1), indexcon(1) replcon(1)
All times are GMT -4. The time now is 05:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy