why output consists of 3 values


 
Thread Tools Search this Thread
# 1  
why output consists of 3 values

Hi there if I have a file called an411
which contains the folowing information
152.78.74.111 [13/Feb/2011:06:52:00 +0000] "GET /datafeed.php HTTP/1.1" 200 2826
152.78.74.211 [13/Feb/2011:06:53:00 +0000] "GET /index.html HTTP/1.1" 200 1190
152.78.74.121 [13/Feb/2011:06:55:00 +0000] "GET / HTTP/1.1" 200 3000
and I want to ouput the number of bytes of the record that contains pattern.
The code:
Code:
 grep '[datafeed.php]' an411 | cut -d" " -f8

returns
2826
1190
3000
Can anyone explain me why it returns 3 values. I think it should return only one because grep matches pattern doesn't it?
Any help Smilie
Thanks in advance Smilie
# 2  
[] is a range of characters to match.

You are telling it to match any line which contains the characters d, a, t, a, f, e, e, d, ., p, h, p.

So, any line which contains p will match.

Any line which contains e will also match.

Any line which contains . will also match.

Any line which contains d will also match.

And so forth.

Leave off the [], and escape the . with \, to match the name 'datafeed.php'.
This User Gave Thanks to Corona688 For This Post:
# 3  
Quote:
Originally Posted by Corona688
[] is a range of characters to match.

You are telling it to match any line which contains the characters d, a, t, a, f, e, e, d, ., p, h, p.

So, any line which contains p will match.

Any line which contains e will also match.

Any line which contains . will also match.

Any line which contains d will also match.

And so forth.

Leave off the [], and escape the . with \, to match the name 'datafeed.php'.
Thanks a lot!!! Smilie
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #7
Difficulty: Easy
Linux was invented by Linux Torvalds.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find values within range and output

Dear All, I am stacked and I ask for your help. Briefly, I have two files, one like this one (file1): 1 101 5 1 102 6 1 103 2 1 104 9 1 105 10 2 301 89 2 302 4 2 303 13 2 304 34 2 305 1 and the other like this one (file2): 1 103 2 303well, what I am trying to do is obtain a... (2 Replies)
Discussion started by: giuliangiuseppe
2 Replies

2. Solaris

Asvc_t values in iostat output

Noticed that asvc_t values in iostat command outputs are mostly more than 100 in our previous iostat analysis. Also found the following detail from an alternate site IO Bottleneck - Disk performance issue - UnixArena ---- 1. asvc_t average service time of active transactions, in... (2 Replies)
Discussion started by: saraperu
2 Replies

3. UNIX for Dummies Questions & Answers

Maximum of the values from the output a query

Following is the output of a command ran inside the script: 2015-01-29-05-38-02 5 2015-01-29-05-38-02 5 2015-01-29-05-38-02 5 2015-01-29-05-38-02 5 2015-01-29-05-38-02 5 2015-01-29-05-38-03 5 2015-01-29-05-38-03 5 2015-01-29-05-38-03 5 2015-01-29-05-38-03 5 2015-01-29-05-38-03 5... (8 Replies)
Discussion started by: Devendra Hupri
8 Replies

4. UNIX for Dummies Questions & Answers

Different values output between du and df

Dear Gurus I have a doubt: Why df -h command shows me that /opt FS has used 3.0G: # df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 9.7G 5.8G 3.5G 63% / /dev/mapper/VolGroup00-LogVol05 226G 171G... (4 Replies)
Discussion started by: orma
4 Replies

5. Shell Programming and Scripting

Extract multiple values from a tnsping output

Hi all, Can anyone help with the following request? I need to extract HOST value, SERVICE_NAME and msec value from a tnsping output and append to a file. The tnsping output is typically as follows: Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS =... (4 Replies)
Discussion started by: jonnyd
4 Replies

6. Shell Programming and Scripting

Is it possible to extract these values from the output

Hi, I would like to search based of "java" and "-Dplatform.home=" and store these two values in bash variables. ps -xef | grep <pid> wlsuser 15160 15144 0 Feb 20 ? 17:27 /app1/jdk150_07/bin/IA64N/java -server -Xms1536m -Dplatform.home=/app1/bea/weblogic92... (13 Replies)
Discussion started by: mohtashims
13 Replies

7. Shell Programming and Scripting

Output breaking when returning multiple values

I've been trying to write a command-line function to grab a website's MX records and their ip addresses. The code below works with domains that only have one MX record: function kmx { mx=`host -t MX $1 | awk '{ print $7 }'`; ip=`host $mx | sed '/IPv6/d;/handled/d' | awk '{ print $4 }'`; ... (8 Replies)
Discussion started by: Azrael
8 Replies

8. Shell Programming and Scripting

Store the output values in array

Hi, How to store the values in array from output result, EG: I have the result like this, ps, google, 1.txt, 1 sam, google, 2.txt, 2 These are the four values followed by comma in two sets. I need to store these values set by set. One set contains four values followed by comma. ... (2 Replies)
Discussion started by: KarthikPS
2 Replies

9. AIX

fr and sr (from vmstat output) values are very high

Hi AIX Expert, the fr (page freed/page replacement) and sr (pages scanned by page-replacement algorithm) values from the vmstat output (see below please) are very high. I usually see this high value during the oracle database backup. In addition, the page scan/page steal/ page faults values... (7 Replies)
Discussion started by: Beginer0705
7 Replies

10. Shell Programming and Scripting

assign values from awk output - help

Dear All, I have a command which gives the number of fields of each line of a comma-separated file. sthng like this : cat QDB_20071126_002.bad | awk -F"," '{ print NF }' I need to assign the first output and the last output of the above command to variables in a script. Need help to do... (4 Replies)
Discussion started by: KrishnaSaran
4 Replies

Featured Tech Videos