Sponsored Content
Full Discussion: grep two strings in a file..
Top Forums Shell Programming and Scripting grep two strings in a file.. Post 302397821 by vivekraj on Tuesday 23rd of February 2010 06:16:49 AM
Old 02-23-2010
Date Matching:

You can use the following command,which will work for any kind of date.

Code:
egrep "[A-Z][a-z]{2} [A-Z][a-z]{2} [0-9]{2} [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [0-9]{0,4}" file


Last edited by Scott; 02-23-2010 at 08:15 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

want to grep only strings in a file?

Hai, Just want to print only alphanumeric in a file ex:- fdsdsklf#@^%$#hf output:- fdsdsklfhf plz, help me:o (5 Replies)
Discussion started by: balan_mca
5 Replies

2. Shell Programming and Scripting

Grep strings from file and put in Column

Dear Experts, My file contains below- GET:SUB:ISI,432350414557432; RESP:0:MD,019352020633:ISI,432350414557432:T11,1:T21,1:T22,1:B16,1:T62,1:BAIC,0:BAOC,1:BOIC,0:BIRO,0:BORO,0:PAID,1; GET:SUB:ISI,432350414581060;... (2 Replies)
Discussion started by: thepurple
2 Replies

3. Shell Programming and Scripting

grep a string in the lines between 2 strings of a file

Hi , Please help me with the following problem: I have an xml file with the following lines <cisco:name> <cisco:mdNm>Cisco Device 7500 A Series</cisco:mdNm> <cisco:meNm>10.1.100.19</cisco:meNm> <cisco:ehNm>/shelf=1</cisco:ehNm> <cisco:subname> <cisco:sptp>Cisco PortA... (8 Replies)
Discussion started by: bhagirathi
8 Replies

4. UNIX for Dummies Questions & Answers

grep command to find multiple strings in multiple lines in a file.

I want to search files (basically .cc files) in /xx folder and subfolders. Those files (*.cc files) must contain #include "header.h" AND x() function. I am writing it another way to make it clear, I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies

5. Shell Programming and Scripting

Delete lines in file containing duplicate strings, keeping longer strings

The question is not as simple as the title... I have a file, it looks like this <string name="string1">RZ-LED</string> <string name="string2">2.0</string> <string name="string2">Version 2.0</string> <string name="string3">BP</string> I would like to check for duplicate entries of... (11 Replies)
Discussion started by: raidzero
11 Replies

6. Shell Programming and Scripting

Grep and replace multiple strings in a file with multiple filenames in a file

Hi, I have a file containing list of strings like i: Pink Yellow Green and I have file having list of file names in a directory j : a b c d Where j contains of a ,b,c,d are as follows a: Pink (3 Replies)
Discussion started by: madabhg
3 Replies

7. Shell Programming and Scripting

Grep multiple strings in a file

Consider i have the below data in my log file. i want to grep using "Monday" and "Working" So the only output i expect is Can you help me with the grep query for Sun Sparc ? Usage: grep -hblcnsviw pattern file . . . (8 Replies)
Discussion started by: mohtashims
8 Replies

8. UNIX for Beginners Questions & Answers

Use strings from nth field from one file to match strings in entire line in another file, awk

I cannot seem to get what should be a simple awk one-liner to work correctly and cannot figure out why. I would like to use patterns from a specific field in one file as regex to search for matching strings in the entire line ($0) of another file. I would like to output the lines of File2 which... (1 Reply)
Discussion started by: jvoot
1 Replies

9. UNIX for Beginners Questions & Answers

Grep: Retrieve two strings from one file to find them anyone on line in another file

I am having trouble matching *two* strings from one file anywhere in a line of a second file, and could use some help getting this figured out. My preference would be to use grep for this because I would like to take advantage of its -A option. The latter is due to the fact that I would like both... (2 Replies)
Discussion started by: jvoot
2 Replies

10. Programming

Python or Shell script to Grep strings from input file and output in csv format

Hi Experts, I am writing a python script to grep string from file and display output in csv file as in attached screenshot https://drive.google.com/file/d/1gfUUdfmQma33tz65NskThYDhkZUGQO0H/view Input file(result_EPFT_config_device) Below is the python script i have prepared as of... (1 Reply)
Discussion started by: as7951
1 Replies
egrep(1)																  egrep(1)

NAME
egrep - search a file for a pattern using full regular expressions SYNOPSIS
/usr/bin/egrep [-bchilnsv] [-e pattern_list] [-f file] [strings] [file...] /usr/xpg4/bin/egrep [-bchilnsvx] [-e pattern_list] [-f file] [strings] [file...] The egrep (expression grep) utility searches files for a pattern of characters and prints all lines that contain that pattern. egrep uses full regular expressions (expressions that have string values that use the full set of alphanumeric and special characters) to match the patterns. It uses a fast deterministic algorithm that sometimes needs exponential space. If no files are specified, egrep assumes standard input. Normally, each line found is copied to the standard output. The file name is printed before each line found if there is more than one input file. /usr/bin/egrep The /usr/bin/egrep utility accepts full regular expressions as described on the regexp(5) manual page, except for ( and ), ( and ), { and }, < and >, and , and with the addition of: 1. A full regular expression followed by + that matches one or more occurrences of the full regular expression. 2. A full regular expression followed by ? that matches 0 or 1 occurrences of the full regular expression. 3. Full regular expressions separated by | or by a NEWLINE that match strings that are matched by any of the expressions. 4. A full regular expression that can be enclosed in parentheses ()for grouping. Be careful using the characters $, *, [, ^, |, (, ), and in full regular expression, because they are also meaningful to the shell. It is safest to enclose the entire full regular expression in single quotes '... '. The order of precedence of operators is [], then *?+, then concatenation, then | and NEWLINE. /usr/xpg4/bin/egrep The /usr/xpg4/bin/egrep utility uses the regular expressions described in the EXTENDED REGULAR EXPRESSIONS section of the regex(5) manual page. The following options are supported for both /usr/bin/egrep and /usr/xpg4/bin/egrep: -b Precede each line by the block number on which it was found. This can be useful in locating block numbers by context (first block is 0). -c Print only a count of the lines that contain the pattern. -e pattern_list Search for a pattern_list (full regular expression that begins with a -). -f file Take the list of full regular expressions from file. -h Suppress printing of filenames when searching multiple files. -i Ignore upper/lower case distinction during comparisons. -l Print the names of files with matching lines once, separated by NEWLINEs. Does not repeat the names of files when the pat- tern is found more than once. -n Precede each line by its line number in the file (first line is 1). -s Work silently, that is, display nothing except error messages. This is useful for checking the error status. -v Print all lines except those that contain the pattern. /usr/xpg4/bin/egrep The following option is supported for /usr/xpg4/bin/egrep only: -x Consider only input lines that use all characters in the line to match an entire fixed string or regular expression to be matching lines. The following operands are supported: file A path name of a file to be searched for the patterns. If no file operands are specified, the standard input is used. /usr/bin/egrep pattern Specify a pattern to be used during the search for input. /usr/xpg4/bin/egrep pattern Specify one or more patterns to be used during the search for input. This operand is treated as if it were specified as -epattern_list. USAGE
See largefile(5) for the description of the behavior of egrep when encountering files greater than or equal to 2 Gbyte ( 2**31 bytes). See environ(5) for descriptions of the following environment variables that affect the execution of egrep: LC_COLLATE, LC_CTYPE, LC_MES- SAGES, and NLSPATH. The following exit values are returned: 0 If any matches are found. 1 If no matches are found. 2 For syntax errors or inaccessible files (even if matches were found). See attributes(5) for descriptions of the following attributes: /usr/bin/egrep +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |Not Enabled | +-----------------------------+-----------------------------+ /usr/xpg4/bin/egrep +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWxcu4 | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ fgrep(1), grep(1), sed(1), sh(1), attributes(5), environ(5), largefile(5), regex(5), regexp(5), XPG4(5) Ideally there should be only one grep command, but there is not a single algorithm that spans a wide enough range of space-time tradeoffs. Lines are limited only by the size of the available virtual memory. /usr/xpg4/bin/egrep The /usr/xpg4/bin/egrep utility is identical to /usr/xpg4/bin/grep -E (see grep(1)). Portable applications should use /usr/xpg4/bin/grep -E. 23 May 2005 egrep(1)
All times are GMT -4. The time now is 10:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy