connecting search patterns in awk with AND


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting connecting search patterns in awk with AND
Prev   Next
# 1  
Old 09-14-2009
connecting search patterns in awk with AND

Hello friends,

I couldnt connect two search patterns in awk, what i want is to search for two words in a log file;
"[0-9]+MB)" and "Done"
i use this code

Code:
/usr/xpg4/bin/awk '/[0-9]+MB)/ {gsub("\(","",$5);print int($5)}' mylog.txt

and i get integer part of (123,45MB) in a log file "mylog" with above code. i want to search the line with also second patternt "Done" for more precise results. how can i do this, i tried this but didnt work:

Code:
/usr/xpg4/bin/awk '/[Dd]one && [0-9]+MB)/ {gsub("\(","",$5);print int($5)}' mylog.txt

I'd appreciate any help.
Thanks in advance
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk pattern match by looping through search patterns

Hi I am using Solaris 5.10 & ksh Wanted to loop through a pattern file by reading it and passing it to the awk to match that value present in column 1 of rawdata.txt , if so print column 1 & 2 in to Avlblpatterns.txt. Using the following code but it seems some mistakes and it is running for... (2 Replies)
Discussion started by: ananan
2 Replies

2. Shell Programming and Scripting

Search for patterns on different lines

im using the following code to search a log for entries on two different lines: awk 'BEGIN{count=0} /'"${firstpattern}"'/,/'"${secondpattern}"'/ { print; if ($0 ~ /'"${thirdpattern}"'/){count++}; } END { print count }' data.txt firstpattern="start error log" secondpattern="i am logging the... (1 Reply)
Discussion started by: SkySmart
1 Replies

3. Shell Programming and Scripting

awk search patterns from file in another

I would like to grep for aaa and bbb and ccc from one line in file1.txt in any order on a line on file2.txt file1.txt aaa bbb ccc ddd fff ggg hhh ddd jjj jjj cccfile2.txt aaa bbb ccc ddd fff ggg --> output whole line since it matches with aaa bbb ccc of file1.txt aaa ddd jjj hhh --> no... (1 Reply)
Discussion started by: sdf
1 Replies

4. Shell Programming and Scripting

Search and count patterns

Hi, I have a text file the contents are like this now i want to search patterns Z , Z etc and count the occurrence of such patterns, after Z value can be any random digits, please help me it is urgent... output like this Z .............>5 Z ............>8 (9 Replies)
Discussion started by: sreejithalokkan
9 Replies

5. Shell Programming and Scripting

Search two patterns using awk to print the variable sum

Coins.txt: gold 1 1986 USA American Eagle gold 1 1908 Austria-Hungary Franz Josef 100 Korona silver 10 1981 USA ingot gold 1 1984 Switzerland ingot gold 1 1979 RSA Krugerrand gold 0.5 1981 RSA Krugerrand gold 0.1 1986 PRC Panda silver 1 1986 USA Liberty dollar gold 0.25 1986 USA Liberty... (2 Replies)
Discussion started by: Ramesh M
2 Replies

6. UNIX for Dummies Questions & Answers

Search a file for patterns from another file to another with awk

Hi all ! I have 2 files: file1: 1|AAA|123456 2|BBB|098765432 ... file2: -|klk|AAA|$123.00|Qty.2|US -|opi|EEE|$23.00|Qty.4|US ... Output: 1|AAA|-|klk|AAA|$123.00|Qty.2|US I would need to search the 3rd field of file2 for the patterns contained in the 2nd field of file1. And... (10 Replies)
Discussion started by: beca123456
10 Replies

7. Shell Programming and Scripting

awk: Multiple search patterns & print in an one liner

I would like to print result of multiple search pattern invoked from an one liner. The code looks like this but won't work gawk -F '{{if ($0 ~ /pattern1/) pat1=$1 && if ($0 ~ /pattern2/) pat2=$2} ; print pat1, pat2}' Can anybody help getting the right code? (10 Replies)
Discussion started by: sdf
10 Replies

8. Shell Programming and Scripting

search multiple patterns

I have two lists in a file that look like a b b a e f c d f e d c I would like a final list a b c d e f I've tried multiple grep and awk but can't get it to work (8 Replies)
Discussion started by: godzilla07
8 Replies

9. Shell Programming and Scripting

Using a script variable in awk search patterns

Hi all, In a script like : job_date=.... ls -l 2>/dev/null | awk -v var =$job_date ' /Name\.Version\.+\.xml$/ { How can i include a script variable job_date store in "var" in the pattern "/Name\.Version\.+\.xml$/" Thanks in advance (12 Replies)
Discussion started by: abhinav192
12 Replies

10. Shell Programming and Scripting

search patterns

hello, i have an input file of about 50,00,000 lines. few of its lines are as follows: <CR:0023498789,TPO-14987084;BO=IC&SUB=ALLP <CF:0023498789,CB=YES;BIL&NC=NO <CF:0023498789,CW=NO;NS=NO <GC:0023498789,CG=YES;TPO&NC=YES <CR:0024659841,TPO-14484621;BO=NO&BA=OC&SUB=ALLH... (1 Reply)
Discussion started by: rochitsharma
1 Replies
Login or Register to Ask a Question
ODFFILESEARCH(1p)					User Contributed Perl Documentation					 ODFFILESEARCH(1p)

NAME
odffilesearch - File selection by keywords SYNOPSIS
odffilesearch -R "D:Documents*.odt" openoffice desktop XML produces the list of the ODF Text documents present in the given directory and its subdirectories, and containing the words "openoffice", "desktop" AND "XML" odffilesearch -command "rm -f %f" "*.ods *.odt" lost dismiss cancel executes the "rm -f filename" (i.e. deletes the file in a Unix system) for each ODT or ODS file present in the current directory and containing the words "lost", "dismiss" AND "cancel" USAGE
odffilesearch [-options] <file filter> <keyword list> DESCRIPTION
This utility allows the user to retrieve a list of files matching a given set of keywords or regular expressions. A file is selected when it contains, in its text and/or in its metadata (title, subject, keywords or description), all the given search strings. The selected files are echoed to the standard output (one file per line), so this utility can be used as a filter piping its results to another program. Alternatively, a given shell command can be launched by the script each time a file matches, allowing on-the-fly processing of the selected documents. The files filter may content one or more space-separated paths. Each path may content jokers. So it's possible to explore several directories and/or several filename patterns. All the arguments after the file filter are processed as search criteria. OPTIONS
-R -recursive include the subdirectories of each given search directory -verbose -trace -debug echo some processing comments -warnings activate the warning messages of the OpenOffice::OODoc API -log <file> like -verbose, but then messages are sent to the given file and don't pollute the standard output -result <file> -output <file> send the list of matching files to the given file and not to the standard output -criteria <file> get search criteria from a file (one per line); the loaded search keywords may be combined with additional criteria passed with the command line, if any. -command <command> -exec <command> execute a shell command for each matching file ; if the command string contains "%f", this substring is replaced with the name of the selected file ; if this option is provided, the selection list is not echoed to the standard output ; if -verbose is on, the value returned by the command is echoed -encoding <encoding> selects the user's character set ; this option is mandatory if one or more search criteria contain characters not belonging to the default character set perl v5.14.2 2008-05-04 ODFFILESEARCH(1p)