Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Finding a word through substring in a file Post 303036519 by utkarshkhanna44 on Monday 1st of July 2019 02:36:15 AM
Old 07-01-2019
Finding a word through substring in a file

I have a text file that has some data like:
Code:
PADHOGOA1 IOP055_VINREG5_1 ( .IO(VINREG5_1), .MONI(), .MON_D(px_IOP055_VINREG5_1_MON_D), .R0T(px_IOP054_VINREG5_0_R0T), .IO1() );

PADV30MA0 IOP056_VOUT3_IN ( .IO(VOUT3_IN), .V30M(px_IOP056_VOUT3_IN_V30M));

PADV30MA0 IOP057_VOUT3_OUT ( .IO(VOUT3_OUT), .V30M(px_IOP057_VOUT3_OUT_V30M) );

PADV15MA0 IOP059_VOUT15_OUT ( .IO(VOUT15_OUT), .V15M(px_IOP059_VOUT15_OUT_V15M) );

PADHOGOA1 IOP064_VREFLB ( .IO(VREFLB), .MONI(), .MON_D(px_IOP064_VREFLB_MON_D), .R0T(px_IOP064_VREFLB_R0T), .IO1() );

My substring is .V30M
I am find this substring and want to display the whole word.

Desired output:
Code:
.V30M(px_IOP057_VOUT3_OUT_V30M)

Please need some help.

Last edited by Scrutinizer; 07-01-2019 at 02:55 PM.. Reason: quote tags -> code tags; + extra code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding word in file then print the preceding....

Hi, I am looking for a way to find a particular word in a file then print a line that precedes this line, as well as this line. Sometimes in a log file there is only one word per line and I need to print one of the lines leading up to the single worded line. Example - I can grep for ouch... (5 Replies)
Discussion started by: g_jumpin
5 Replies

2. Shell Programming and Scripting

finding the last substring...

hii, i want to know the shell command for finding the last occurance of a substring in string.. i can use grep command or sed to find out the occurance of a substring in a string but how do i find out the last occurance.shud i use grep amd and cut the string everytime and store it in a new... (7 Replies)
Discussion started by: cutelucks
7 Replies

3. Shell Programming and Scripting

help for shell script of finding shortest substring from given string by user

please give me proper solution for finding a shortest substring from given string if string itself and first char and last char of that substr are also given by user if S="dpoaoqooroo" and FC="o" and LC="o",then shortest substr is "oo" and rest of the string is "dpoaoqroo" i have code but it is... (1 Reply)
Discussion started by: pankajd
1 Replies

4. Shell Programming and Scripting

Finding a word in a file

Hi frndz, i have a flat file like, xxx yyy zzz sss aaa bbb yyy xxx rrr sss ttt yyy ddd zzzz cccc.. look, in this file i want to fetch the substring from one yyy to another one and need to print it then from next values between yyy's.. can you please give me some inputs on this.. ... (10 Replies)
Discussion started by: smr_rashmy
10 Replies

5. Shell Programming and Scripting

need help with finding a word in file's contents

Hi, I need to check if a particular name is already in the file or not and i am using following code for this... match=$(grep -n -e "$output1" outputfiles.txt ) where output1 is the variable name having names in it and outputfiles.txt is the file name ..and i am using ksh can anybosy... (6 Replies)
Discussion started by: manmeet
6 Replies

6. Shell Programming and Scripting

Finding longest common substring among filenames

I will be performing a task on several directories, each containing a large number of files (2500+) that follow a regular naming convention: YYYY_MM_DD_XX.foo_bar.A.B.some_different_stuff.EXT What I would like to do is automatically discover the part of the filenames that are common to all... (1 Reply)
Discussion started by: cmcnorgan
1 Replies

7. Shell Programming and Scripting

Finding duplicates from positioned substring across lines

I have million's of records each containing exactly 50 characters and have to check the uniqueness of 4 character substring of 50 character (postion known prior) and report if any duplicates are found. Eg. data... AAAA00000000000000XXXX0000 0000000000... upto50 chars... (2 Replies)
Discussion started by: gapprasath
2 Replies

8. Shell Programming and Scripting

AWK Substring without cutting off word

Can someone help me to make this code without cutting off words ni the string? awk '{for(i=1;i<length;i+=100) print substr($0,i,100)}' Thank you! (4 Replies)
Discussion started by: sanantonio7777
4 Replies

9. Shell Programming and Scripting

Bash - Extracting whole word containing substring

hello. I get this text when using some command : S | Name | Type | Version | Arch | Repository --+-----------------+---------+---------+------+------------- | AdobeReader_enu | package | 9.5.4-1 | i486 | zypper_local I need to get "AdobeReader_enu" from the the pattern "Ado"... (7 Replies)
Discussion started by: jcdole
7 Replies

10. Shell Programming and Scripting

Finding pattern in a text file and returning a part of the word

Dear All, assume that we have a text file or a folder of files, I want to find this pattern followers*.csv in the text file , and get * as the output. There are different matches and * means every character. Thank you in advance. Best, David (1 Reply)
Discussion started by: davidfreed
1 Replies
GID(1)                                                             User Commands                                                            GID(1)

NAME
gid - Query ID database and report results. SYNOPSIS
gid [OPTION]... PATTERN... DESCRIPTION
Query ID database and report results. By default, output consists of multiple lines, each line containing the matched identifier followed by the list of file names in which it occurs. -f, --file=FILE file name of ID database -i, --ignore-case match PATTERN case insensitively -l, --literal match PATTERN as a literal string -r, --regexp match PATTERN as a regular expression -w, --word match PATTERN as a delimited word -s, --substring match PATTERN as a substring Note: If PATTERN contains extended regular expression metacharacters, it is interpreted as a regular expression substring. Other- wise, PATTERN is interpreted as a literal word. -k, --key=STYLE STYLE is one of `token', `pattern' or `none' -R, --result=STYLE STYLE is one of `filenames', `grep', `edit' or `none' -S, --separator=STYLE STYLE is one of `braces', `space' or `newline' and only applies to file names when `--result=filenames' The above STYLE options control how query results are presented. Defaults are --key=token --result=filenames --separator=space -F, --frequency=FREQ find tokens that occur FREQ times, where FREQ is a range expressed as `N..M'. If N is omitted, it defaults to 1, if M is omitted it defaults to MAX_USHRT -a, --ambiguous=LEN find tokens whose names are ambiguous for LEN chars -x, --hex only find numbers expressed as hexadecimal -d, --decimal only find numbers expressed as decimal -o, --octal only find numbers expressed as octal By default, searches match numbers of any radix. --help display this help and exit --version output version information and exit REPORTING BUGS
Report bugs to bug-idutils@gnu.org SEE ALSO
The full documentation for gid is maintained as a Texinfo manual. If the info and gid programs are properly installed at your site, the command info gid should give you access to the complete manual. gid - 4.5 August 2010 GID(1)
All times are GMT -4. The time now is 07:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy