Sponsored Content
Top Forums Shell Programming and Scripting How to handle grepping variable data containing wildcards? Post 302983356 by abercrom on Monday 10th of October 2016 02:15:46 PM
Old 10-10-2016
You got me looking back at the quotes again and I found the problem where I initially strip out the fields I need for the pattern. What a dumb mistake!
Yes, I should try to make it simpler. Smilie
Thanks!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grepping using multiple wildcards

Is there anyway you can grep using multiple wildcards? When I run the below line the results return fine; grep 12345 /usr/local/production/soccermatchplus/distributor/clients/*/out/fixtures.xml | awk -F/ '{print $8}' However ideally, I need it to grep for; grep 12345... (3 Replies)
Discussion started by: JayC89
3 Replies

2. UNIX for Dummies Questions & Answers

grepping a variable

I need to pass a parameter that will then be grepped. I need it to grep /paramater and then have a space so if 123 was passed my grep would be grep '/123 ' sample.log this works fine from the command line but when i try and set it searchThis="/$2 " and then run grep $searchThis... (6 Replies)
Discussion started by: magnia
6 Replies

3. Shell Programming and Scripting

Grepping Date Variable

Hello, I would like for the user to input the date for a particular log file, then have the input sent to a variable, which is then used via grep to extra the logs for the specific date the user request. I did some searching, but I still don't understand why I'm not seeing any result. ... (4 Replies)
Discussion started by: ravzter
4 Replies

4. Shell Programming and Scripting

problem in using cgi_script to handle form data

Hi, I have an HTML form through which I get some text as input. i need to run a shell script say script.sh inside a perl-cgi script named main_cgi.sh on the form input. I want to write the contents of the form in a file and then perform some command line operations like grep, cat on the text... (0 Replies)
Discussion started by: piyush_priya
0 Replies

5. Shell Programming and Scripting

Help with grepping data from a text file

Hello, I have a text file which contains a list of strings which I want to grep from another file where these strings occur and print out only these lines. I had earlier used the grep command where File1 was the file containing the strings to be grepped (Source File) and File2 the Target File... (4 Replies)
Discussion started by: gimley
4 Replies

6. Shell Programming and Scripting

Grepping for variable in brackets

I have a script which reads a number out of a log file. The pertinent line is this: cat /tmp/listofnumbers When I run cat /tmp/listofnumbers what I am seeing is on each line. I am trying to make the script read from that file and grep for a variable like the following line should do: ... (4 Replies)
Discussion started by: newbie2010
4 Replies

7. Shell Programming and Scripting

Grepping data using awk

Hello, I have a data in file 1 2000000024776 2000000026979 2000000033355 2000000036309 2000000041291 2000000042679 2000000067221 and in file 2 its like this 2000000024776 16 2000000026979 16 2000000033355 16 (2 Replies)
Discussion started by: mirwasim
2 Replies

8. Shell Programming and Scripting

Grepping the data between 2 date ranges

Hi There, Good Day !! I have txt file containing data in the below format. There are many lines, here i have mentioned for example. cat remo.txt 2/3/2017 file1 3/4/2016 file2 6/6/2015 file5 1/1/2018 file3 4/3/2014 file4 - - - I need to grep the file names for given date rage... (11 Replies)
Discussion started by: kumar85shiv
11 Replies

9. UNIX for Beginners Questions & Answers

Expand Variables and Wildcards into another variable.

Dear Forum members, I am having trouble getting the complete filename (and directory path) in a variable. Output directory mentioned in the code have three files: DISPLAY_CITY_DETAILS_15-05-2019-08-29-26_MIGRATE_london.out DISPLAY_CITY_DETAILS_15-05-2019-08-29-26_MIGRATE_paris.out... (4 Replies)
Discussion started by: chetanojha
4 Replies

10. UNIX for Beginners Questions & Answers

Grepping for one variable while using awk to parse an associated variable

Im trying to search for a single variable in the first field and from that output use awk to extract out the lines that contain a value less than a value stored in another variable. Both the variables are associated with each other. Any guidance is appreciated. File that contains the... (6 Replies)
Discussion started by: ncwxpanther
6 Replies
pick(1mh)																 pick(1mh)

Name
       pick - select messages by content

Syntax
       pick [ +folder ] [ msgs ] [ options ]

Description
       The command lets you search messages in a folder on a diverse range of search criteria.

       You can search the mail headers or the text of some or all of the messages within a folder for the specified criteria.  You can use pattern
       matching or date constraint operations.	You can use the messages that you find with other  MH  commands,  or  you  can	place  them  in  a
       sequence.

       By  default, searches all the messages in the current folder.  You can specify a folder other than the current folder using the +foldername
       option.	Also, if you do not want to search all messages within the folder, you can specify more than one message or a  range  of  messages
       using the message numbers.

       You  can search on the contents of the most common header fields by giving the name of the field as an option, preceded by a dash (-).  The
       command allows you to specify the following header fields in this way: To:, cc:, Date:, From:, and Subject:.  You can also search the  con-
       tents of any other header field by preceding the name of the field with two dashes.

       The also allows you to introduce time constraints.  You can search for messages sent before, after, or between specified dates.

   Combining pick with Other Commands
       You can combine the output of directly with any MH command.  by using a technique called back-quoting.  Enclose the command and its associ-
       ated arguments and options in back quotes (`).  The system performs back-quoted commands first.	In the following example, the  command	is
       performed first, and the output is then listed by the command:
       % scan `pick -from jones`
	  3  16/01 jones	      Meeting 10.00 tomorrow<<There wi
	 17  22/01 jones	      Minutes of meeting 16/1<<Any com
	 21  01/02 jones	      Next week's meeting cancelled<<T

       If finds that there is no mail from Jones, it will output the illegal character 0.  This will cause the command to fail gracefully.

       You  can  use  back-quoting  to	combine with any MH command.  For more information on back-quoting, see the reference page for your ULTRIX
       shell; for example, or

Options
       -after date
		 Searches for messages sent after the specified date.  This command can be used with pattern-matching options, and  also  in  con-
		 junction  with  the -before option to specify a date range.  The date must be enclosed in double quotes (").  This option accepts
		 RFC 822-style dates.  It also accepts days of the week, and the special dates today and yesterday.  Days of the week always refer
		 to days in the past; for example, saturday refers to last Saturday, not to next Saturday.

		 By  default,  consults the Date: field of the message.  If you wish to use the date in another header field, you can specify this
		 with the -datefield option.

       -before date
		 Searches for messages sent before the specified date.	This command can be used with pattern-matching options, and also  in  con-
		 junction  with  the  -after option to specify a date range.  The date must be enclosed in double quotes (").  This option accepts
		 RFC 822-style dates.  It also accepts days of the week, and the special dates today, tomorrow, and yesterday.	Days of  the  week
		 always refer to days in the past; for example, saturday refers to last Saturday, not to next Saturday.

		 By  default,  consults the Date: field of the message.  If you wish to use the date in another header field, you can specify this
		 with the -datefield option.

       -cc pattern
		 Searches for the specified pattern in the cc: field of messages.  This option is case-insensitive: lower- and upper-case  letters
		 are  treated  as identical.  So a search for the pattern phillips would also find Phillips and PHILLIPS.  If the pattern contains
		 spaces, you must enclose it in double quotes (").

       -date pattern
		 Searches for messages sent on a specified date.  This option consults the Date: field of messages.  You  must	enclose  the  date
		 that you give in double quotes (") if it contains spaces.

       -datefield field
		 Specifies  the  header  field to be used by the -before and -after options.  By default, these options consult the Date: field of
		 the message header.  You can specify a different header field by naming it with this option.  The -datefield option must  precede
		 the -before or -after options it is used with.

       -from pattern
		 Searches  for	the specified pattern in the From: field of messages.  This option is case-insensitive: lower- and upper-case let-
		 ters are treated as identical.  So a search for the pattern phillips would also find Phillips and PHILLIPS.  If the pattern  con-
		 tains spaces, you must enclose it in double quotes (").

       -help	 Prints a list of the valid options to this command.

       -list
       -nolist	 The  -list  option lists the numbers of the messages that have met the search criteria.  This is the usual default behavior of If
		 you use the -nolist option, indicates how many messages met the search criteria.

		 If you use the -sequence option to add the messages found to a sequence, the default behavior is to use the -nolist option.

       -public
       -nopublic Sets the read permissions of sequences.  Normally, when you create a sequence with the -sequence option, the sequence will not be
		 accessible  to  other	MH  users.  The -public option makes the sequence accessible to other MH users.  You can use the -nopublic
		 option to ensure that the sequence that you create is only accessible to yourself.

       -search pattern
		 Searches the entire message for the specified string.	Each line of the message is searched for the  pattern  that  you  specify.
		 The  -search option is a modified Like this option is case-sensitive; it treats upper- and lower-case letters as different.  So a
		 search for the word strawberries would not find a messages which contained the word STRAWBERRIES.  If the search pattern contains
		 spaces, you must enclose it in double quotes (").

       -sequence name
		 Specifies  a  sequence  in which places the messages found.  For more information on sequences, see The name of the sequence must
		 begin with a letter, and must consist entirely of alphabetic or numeric characters; no punctuation is allowed.

       -subject pattern
		 Searches for the specified pattern in the Subject: field of messages.	This option is	case-insensitive:  lower-  and	upper-case
		 letters  are  treated	as identical.  So a search for the pattern phillips would also find Phillips and PHILLIPS.  If the pattern
		 contains spaces, you must enclose it in double quotes (").

       -to pattern
		 Searches for the specified pattern in the To: field of messages.  This option is case-insensitive: lower- and upper-case  letters
		 are  treated  as identical.  So a search for the pattern phillips would also find Phillips and PHILLIPS.  If the pattern contains
		 spaces, you must enclose it in double quotes (").

       -zero
       -nozero	 Specifies whether to zero existing sequences before adding new messages.  Normally, removes all existing messages from a sequence
		 before  adding messages to it.  If you specify the -nozero option, will add the messages it finds to the existing contents of the
		 sequence.  This option only works with the -sequence option.

       --component pattern
		 Searches a specified header field.  If you wish to search for a pattern in a particular header field, you can specify	the  field
		 by  placing  two  dashes  (-)	before	the name of the field.	This option is case-insensitive: lower- and upper-case letters are
		 treated as identical.	So a search for the pattern phillips would also find Phillips and PHILLIPS.  If the pattern contains  spa-
		 ces, you must enclose it in double quotes (").

		 The  command recognizes the following common header fields: To:, cc:, Date:, From:, and Subject:.  You can search these fields by
		 preceding the name with one dash only.

       In addition to the above options, you can direct to start its search a specified number of days ago.  To do this,  precede  the	number	of
       days with a dash (-).  For example, the following command searches all messages sent in the last ten days:
       % pick -subject strawberries -10
       1
       6

       The  command also supports complex boolean operations.  The -not, -or and -and options allow you to modify the behavior of pattern-matching
       options.  In the following command, the -not option means that searches for messages that were not from fred:
       % pick -not -from fred

       In the next example, the -or option finds all messages from fred or from david.	If the -or option is not used, searches for messages  with
       both the string fred and the string david in the From: field.
       % pick -from fred -or -from david

       The  pattern-matching  options normally take precedence over -not, which in turn takes precedence over -and, which in turn takes precedence
       over -or.

       You can override the default precedence with the -lbrace and -rbrace options.  These act just like opening and closing parentheses in logi-
       cal expressions.

Restrictions
       The  sequence  name,  punctuation and message list must not exceed 1024 characters.  In practice, this gives a reasonable limit of approxi-
       mately 200 non-consecutive messages in a sequence.

Examples
       The first example finds all the mail in the current folder that was sent by Christine:
       % pick -from christine
       1
       3
       8

       In the next example, searches messages 10-20 in the folder for messages that were sent to Kafka:
       % pick +sent 10-20 -to Kafka
       pick: no messages match specification

       The next example finds all messages from Jack, and places them in a sequence called testing:
       % pick -from Jack -sequence testing
       3 hits

       The final example finds all messages sent to Holloway since 10th June:
       % pick -to holloway -after "10 Jun 90"
       19

Profile Components
       Path:   To determine your Mail directory

Files
       The user profile.

See Also
       csh(1), ed(1), grep(1), sh(1), inc(1mh), mark(1mh)

																	 pick(1mh)
All times are GMT -4. The time now is 07:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy