06-11-2015
Quote:
Originally Posted by
Don Cragun
You showed us two examples of code you had written that apparently did not do what you want. RavinderSingh13 suggested some code that strips off leading whitespace characters and prints lines that match your requested string after doing that. And, you just repeated your original, ambiguous statement about what you want.
What output were you expecting from the input you supplied? Were you expecting the lines RavinderSingh13's code extracted? Were you expecting no lines to be matched (due to leading or trailing whitespace that is not in the string binutils1_test)? Were you expecting every line that contained that string to be printed?
I expect the line that contains binutils1_test to be print, which maybe contains space or tab, I don't care
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi, Can you help please.
I have the following comand:
if ]; then
l_valid_string="Y"
fi
The problem I am trying to solve is that my l_string = ABC and my file contains
ABC
ABC_EFG
I only want back the value ABC exact match. (3 Replies)
Discussion started by: CAGIRL
3 Replies
2. UNIX for Dummies Questions & Answers
Hi all,
Is anyone able to help with the following query?
I have an input file with several lines of words, e.g.
"hellolaylahello"
"hellohellohellolayla"
I want to search for the exact string "hello" in each line and display:
2 "hellolaylahello"
3 "hellohellohellolayla"
I... (11 Replies)
Discussion started by: dr_sabz
11 Replies
3. Shell Programming and Scripting
Hi
I have a string of the form XY_X1998.10.500.
I want to check in a script that the middle part is always 10. How to achieve this?
e.g the input can be XY_X1998.20.500 OR XY_X1998.50.500
OR XY_X1998.10.500.
I have to print Yes everytime the middle value is 10 and NO when the middle... (2 Replies)
Discussion started by: skyineyes
2 Replies
4. Shell Programming and Scripting
Dear Friends,
Anybody knows how to match exact lines only in multilinear.
Input file:
apple
orange
orange
apple
apple
orange
Desired output:
fruit
orange
apple
fruit
i used the command (1 Reply)
Discussion started by: vasanth.vadalur
1 Replies
5. Shell Programming and Scripting
I am trying to match a pattern exactly in a shell script. I have tried two methods
awk '/\<mpath${CURR_MP}\>/{print $1 $2}' multipath
perl -ne '/\bmpath${CURR_MP}\b/ and print' /var/tmp/multipath
Both these methods require that I use the escape character. I am guessing that is why... (8 Replies)
Discussion started by: bash_in_my_head
8 Replies
6. Shell Programming and Scripting
Hi All,
I'm writing unix script, it should find exact matching in search string. Looks simple but when i started i'm stuck to find the exact match character string.
The unix script reads the records from DB Table. The table will have values something likes these
Feed : A Feed File name :... (3 Replies)
Discussion started by: luckybalaji
3 Replies
7. Shell Programming and Scripting
I have a file that contains the 2 following lines (from /proc/mounts)
/dev/sdc1 /mnt/backup2 xfs rw,relatime,attr2,noquota 0 0
/dev/sdb1 /mnt/backup xfs rw,relatime,attr2,noquota 0 0
I need to match the string in the second column exactly so that only one result is returned, e.g.
> grep... (2 Replies)
Discussion started by: jelloir
2 Replies
8. Shell Programming and Scripting
Hi All,
I am breaking my head in trying to get a command that will exactly match my given string. I have searched net and found few of the options -
grep -F $string file
grep -x $string file
grep "^${string}$" file
awk '/"${string}"/ {print $0}' file
strangely nothing seems to... (3 Replies)
Discussion started by: dips_ag
3 Replies
9. Shell Programming and Scripting
I have a workaround to the problem i m posting, however if someone wants to look at my query and respond ... i will appreciate.
This is in reference to this thread -> https://www.unix.com/shell-programming-and-scripting/267630-extract-between-two-exact-matched-strings.html
I have data.txt as... (11 Replies)
Discussion started by: mohtashims
11 Replies
10. Shell Programming and Scripting
I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output.
$1 in database.txt will be in list.txt as a partial match. $2 of database.txt... (2 Replies)
Discussion started by: cmccabe
2 Replies
LEARN ABOUT SUSE
grephistory
GREPHISTORY(1) InterNetNews Documentation GREPHISTORY(1)
NAME
grephistory - Query the INN history database
SYNOPSIS
grephistory [-eilnqsv] [-f db] [message-id]
DESCRIPTION
grephistory queries the INN history database for information about the specified message-ID. If no flags are given, the program prints the
storage API token of the corresponding article, or "/dev/null" if the article is listed in the history database but not stored on the
server. If the message-ID cannot be found in the database, grephistory will print "grephistory: not found" and exit with a non-zero
status.
Be sure to escape any special characters in the message ID from the shell. Single quotes are recommended for this purpose since many
message-IDs contain dollar signs.
OPTIONS
-e Only print the storage token if the article is stored on the system. (In other words, suppress the "/dev/null" or "not found" output
for missing or remembered articles.)
-f db
Query the history database db rather than the default history database.
-i Rather than expecting a message-ID on the command line, grephistory will read a list of message-IDs on standard input, one per line.
Leading and trailing whitespace is ignored, as are any malformed lines. It will print on standard output those message-IDs which are
not found in the history database. This is used when processing "ihave" control messages.
-l Display the entire line from the history database, rather than just the storage API token. If the message-ID is present in the history
database but has no storage API token, grephistory does not print anything.
-n If the message-ID is present in the history database but has no storage API token, print "/dev/null" and exit successfully. This can
happen if an article has been cancelled or expired, but history information has still been retained. This is the default behavior.
-q Don't print any message, but still exit with the appropriate status.
-s Rather than expecting a message-ID on the command line, grephistory will read a list of message-IDs on standard input, one per line.
Leading and trailing whitespace is ignored, as are any malformed lines. It will print on standard output the storage API tokens for
any articles that are still available, one per line. This flag is used when processing "sendme" control messages.
-v Print out the hash of the message-ID for diagnostic purposes, as well as any other requested information. This flag is not useful with
-i or -s.
EXAMPLES
In case the requested article is not listed in the history database:
% grephistory '<unknown.article@news.example.com>'
grephistory: not found
% grephistory -v '<unknown.article@news.example.com>'
grephistory: not found (hash is 501C66C22932BA91131186D7218201EB)
In case the requested article is listed in the history database but not stored on the server:
% grephistory '<remembered.article@news.example.com>'
/dev/null
In case the requested article is stored on the server:
% grephistory '<87fxeaay1z.fsf@windlord.stanford.edu>'
@02014A2DD6231FCC00000000000000000000@
% grephistory -l '<87fxeaay1z.fsf@windlord.stanford.edu>'
[B6DDF69376E3CC199246CEC949B3ACAC] 1244517923~-~1244517912 @02014A2DD6231FCC00000000000000000000@
With sm, we can retrieve the article, and get its posting date:
% grephistory '<87fxeaay1z.fsf@windlord.stanford.edu>' | sm | grep Date
Date: Mon, 08 Jun 2009 20:25:12 -0700
% convdate -dc 1244517912
Tue, 9 Jun 2009 03:25:12 +0000 (UTC)
It matches the number recorded in history as for its posting date.
HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> for InterNetNews. Rewritten in POD by Russ Allbery <rra@stanford.edu>.
$Id: grephistory.pod 8582 2009-08-19 08:04:32Z iulius $
SEE ALSO
history(5), inn.conf(5), sm(1).
INN 2.5.2 2009-09-11 GREPHISTORY(1)