Sponsored Content
Top Forums Shell Programming and Scripting Need a word which just comes next to after grep of a specific word Post 302879856 by Akshay Hegde on Monday 16th of December 2013 07:59:09 AM
Old 12-16-2013
Quote:
Originally Posted by RavinderSingh13
Thank you Akshay for the great commands. Could you please explain the same please, will be grateful to you.


Thanks,
R. Singh

Code:
grep -Po -m1 '(?<=PREF:).*(?=AVAIL:)'

P---> Interprets as regular perl expression

o---> Printout only what is matched

m 1 --> Max count 1, after match stop reading file

( --> start grouping

?<=PRES: --> positive look behind, but don't match PRES:

) --> end grouping

.* --> anything after positive look behind to negative look behind will be part of match

( --> start grouping

?=AVAIL: --> negative look behind

) --> end grouping

Hope its fine.
This User Gave Thanks to Akshay Hegde For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep a word from a specific line

for example: searches only for single word for single word this is line three match=$(grep -n -e "single" data.txt) this command will stored "..... single ...... single" into search. how can i grep the single word just from line 2 only?? (3 Replies)
Discussion started by: blurboy
3 Replies

2. UNIX for Dummies Questions & Answers

how to grep for a word and display only the word

Hi, When we "grep" for a word in a file, it returns the lines containing the word that we searched for. Is there a way to display only the words and not the entire line containing them. Thanks Ananth (6 Replies)
Discussion started by: ananthmm
6 Replies

3. Shell Programming and Scripting

Grep out specific word and only that word

ok, so this is proving to be kind of difficult even though it should not be. say for instance I want to grep out ONLY the word fkafal from the below output, how do I do it? echo ajfjf fjfjf iafjga fkafal foeref afoafahfia | grep -w "fkafal" If i run the above command, i get back all the... (4 Replies)
Discussion started by: SkySmart
4 Replies

4. Shell Programming and Scripting

grep part of word or Another word from a string

Hi all, FileOne family balance >>>>> 0 0 0 0 java.io.FileNotFoundException: Settings.xml (No such file or directory) at java.io.FileInputStream.open(Native Method) .. .... ..... ..... java.lang.NullPointerException ... ..... ...... Stacktrace: at... (2 Replies)
Discussion started by: linuxadmin
2 Replies

5. UNIX for Dummies Questions & Answers

How to print line starts with specific word and contains specific word using sed?

Hi, I have gone through may posts and dint find exact solution for my requirement. I have file which consists below data and same file have lot of other data. <MAPPING DESCRIPTION ='' ISVALID ='YES' NAME='m_TASK_UPDATE' OBJECTVERSION ='1'> <MAPPING DESCRIPTION ='' ISVALID ='NO'... (11 Replies)
Discussion started by: tmalik79
11 Replies

6. 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

7. Shell Programming and Scripting

Fetch entries in front of specific word till next word

Hi all I have following file which I have to edit for research purpose file:///tmp/moz-screenshot.png body, div, table, thead, tbody, tfoot, tr, th, td, p { font-family: &quot;Liberation Sans&quot;; font-size: x-small; } Drug: KRP-104 QD Drug: Placebo Drug: Metformin|Drug:... (15 Replies)
Discussion started by: Priyanka Chopra
15 Replies

8. Shell Programming and Scripting

Search for a specific word and print only the word from the input file

Hi, I have a sample file as shown below, I am looking for sed or any command which prints the complete word only from the input file. Ex: $ cat "sample.log" I am searching for a word which is present in this file We can do a pattern search using grep but I need to cut only the word which... (1 Reply)
Discussion started by: mohan_kumarcs
1 Replies

9. Shell Programming and Scripting

Grep for a word or word with underscore

I have a file "test" with following contents: cat test abc abcd_efg abc_abc I want to only grep for abc or abc_ without getting other results, how do I achieve this? If I use grep -w abc test option I get only abc and not abc_. If I use egrep "abc|abc_" test its still printing... (3 Replies)
Discussion started by: ctrld
3 Replies

10. UNIX for Beginners Questions & Answers

Grep or awk a unique and specific word across many fields

Hi there, I have data with similar structure as this: CHR START-SNP END-SNP REF ALT PATIENT1 PATIENT2 PATIENT3 PATIENT4 chr1 69511 69511 A G homo hetero homo hetero chr2 69513 69513 T C . hetero homo hetero chr3 69814 69814 G C . . homo homo chr4 69815 69815 C A hetero . . hetero is... (10 Replies)
Discussion started by: daashti
10 Replies
LOCALE(7)						     Linux Programmer's Manual							 LOCALE(7)

NAME
locale - Description of multi-language support SYNOPSIS
#include <locale.h> DESCRIPTION
A locale is a set of language and cultural rules. These cover aspects such as language for messages, different character sets, lexigraphic conventions, etc. A program needs to be able to determine its locale and act accordingly to be portable to different cultures. The header <locale.h> declares data types, functions and macros which are useful in this task. The functions it declares are setlocale() to set the current locale, and localeconv() to get information about number formatting. There are different categories for local information a program might need; they are declared as macros. Using them as the first argument to the setlocale() function, it is possible to set one of these to the desired locale: LC_COLLATE This is used to change the behaviour of the functions strcoll() and strxfrm(), which are used to compare strings in the local alpha- bet. For example, the German sharp s is sorted as "ss". LC_CTYPE This changes the behaviour of the character handling and classification functions, such as isupper() and toupper(), and the multi-byte character functions such as mblen() or wctomb(). LC_MONETARY changes the information returned by localeconv() which describes the way numbers are usually printed, with details such as decimal point versus decimal comma. This information is internally used by the function strfmon(). LC_MESSAGES changes the language messages are displayed in and how an affirmative or negative answer looks like. The GNU C-library contains the gettext(), ngettext(), and rpmatch() functions to ease the use of these information. The GNU gettext family of functions also obey the environment variable LANGUAGE. LC_NUMERIC changes the information used by the printf() and scanf() family of functions, when they are advised to use the locale-settings. This information can also be read with the localeconv() function. LC_TIME changes the behaviour of the strftime() function to display the current time in a locally acceptable form; for example, most of Europe uses a 24-hour clock vs. the US' 12-hour clock. LC_ALL All of the above. If the second argument to setlocale() is empty string, "", for the default locale, it is determined using the following steps: 1. If there is a non-null environment variable LC_ALL, the value of LC_ALL is used. 2. If an environment variable with the same name as one of the categories above exists and is non-null, its value is used for that cat- egory. 3. If there is a non-null environment variable LANG, the value of LANG is used. Values about local numeric formatting is made available in a struct lconv returned by the localeconv() function, which has the following declaration: struct lconv { /* Numeric (non-monetary) information. */ char *decimal_point; /* Decimal point character. */ char *thousands_sep; /* Thousands separator. */ /* Each element is the number of digits in each group; elements with higher indices are farther left. An element with value CHAR_MAX means that no further grouping is done. An element with value 0 means that the previous element is used for all groups farther left. */ char *grouping; /* Monetary information. */ /* First three chars are a currency symbol from ISO 4217. Fourth char is the separator. Fifth char is ' '. */ char *int_curr_symbol; char *currency_symbol; /* Local currency symbol. */ char *mon_decimal_point; /* Decimal point character. */ char *mon_thousands_sep; /* Thousands separator. */ char *mon_grouping; /* Like `grouping' element (above). */ char *positive_sign; /* Sign for positive values. */ char *negative_sign; /* Sign for negative values. */ char int_frac_digits; /* Int'l fractional digits. */ char frac_digits; /* Local fractional digits. */ /* 1 if currency_symbol precedes a positive value, 0 if succeeds. */ char p_cs_precedes; /* 1 if a space separates currency_symbol from a positive value. */ char p_sep_by_space; /* 1 if currency_symbol precedes a negative value, 0 if succeeds. */ char n_cs_precedes; /* 1 if a space separates currency_symbol from a negative value. */ char n_sep_by_space; /* Positive and negative sign positions: 0 Parentheses surround the quantity and currency_symbol. 1 The sign string precedes the quantity and currency_symbol. 2 The sign string succeeds the quantity and currency_symbol. 3 The sign string immediately precedes the currency_symbol. 4 The sign string immediately succeeds the currency_symbol. */ char p_sign_posn; char n_sign_posn; }; CONFORMS TO
POSIX.1 The GNU gettext functions are specified in LI18NUX2000. SEE ALSO
setlocale(3), localeconv(3), locale(1), localedef(1), nl_langinfo(3), gettext(3), ngettext(3), rpmatch(3), strfmon(3), strcoll(3), strxfrm(3), strftime(3) Linux 1993-04-24 LOCALE(7)
All times are GMT -4. The time now is 10:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy