05-27-2008
How to count a string only if has a particular string
Hi,
I have a file which has the contents as like below,
10:22:23 Good 10.20.30.40
10:22:23 Good 10.20.30.41
10:22:23 Good 10.20.30.55
10:22:23 Hello 10.20.30.40
10:22:23 Bad 10.20.30.40
10:22:23 Hello 10.20.30.41
10:22:23 Hello 10.20.30.41
10:22:23 Bad 10.20.30.41
10:22:23 Bad 10.20.30.55
I need the output like this,
Number of Good-Bad has Hello string inbetween them
(account Good-bad based on the ip in the 3rd column)
For the above file output should be like,
Number of Good-Bad has Hello string: 2
Number of Good-Bad without Hello String :1
Please suggest a script for this....
Thanks in advance,
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi there, it may quite easy but i've tried my best to editing this awk script but didn't get to solution.
Scripts:BEGIN { Header = "1 ";
FileType = "NBI";
#Count = Count + 1;
printf("%-2s%-3s%03s%-14s%-84s\r\n", Header, FileType, Count, FileSeq, SysTime, " ");
}
{ ... (13 Replies)
Discussion started by: Helmi
13 Replies
2. Shell Programming and Scripting
I have a file. I want to count the time for one string appears in this file
Example:
56
73
34
79
90
56
34
Expected results
2:56
1:73
2:34 (1 Reply)
Discussion started by: anhtt
1 Replies
3. UNIX for Dummies Questions & Answers
Hi all,
I like to know how to get the count of each character in a given word. Using the commands i can easily get the output. How do it without using the commands ( in shell programming or any programming)
if you give outline of the program ( pseudo code )
i used the following commands
... (3 Replies)
Discussion started by: itkamaraj
3 Replies
4. Shell Programming and Scripting
I am writing ksh to check for duplicate records in two different set of tables on oracle database, to get this i am running two plsql qurries at a time through the ksh, so the output of the qurries will be stored in variable say "SQL_STRING". So now to say if duplicate records exists in table or... (3 Replies)
Discussion started by: vpv0002
3 Replies
5. Shell Programming and Scripting
I am writing a ksh to check for duplicate records in two different set of tables on oracle database, to get this i am running two plsql qurries at a time through the ksh, so the output of the qurries will be stored in variable say "SQL_STRING". So now to say if duplicate records exists in table or... (6 Replies)
Discussion started by: vpv0002
6 Replies
6. Shell Programming and Scripting
Hi,
Please help me in finding the number of occurences of the string.
Example: Apple, green, blue, Apple, Orange, green, blue are the strings can be even in the next line.
The o/p should look as:
Word Count
----- -----
Apple 2
green 2
Orange 1
blue 2
Thanks (2 Replies)
Discussion started by: acc888
2 Replies
7. Shell Programming and Scripting
Hi, Gurus,
I have a requirement which need count string length.
eg.
abc
bcde
defge
want to get following:
abc 3
bcde 4
defge 5
:wall:
thanks in advance! (6 Replies)
Discussion started by: ken002
6 Replies
8. Shell Programming and Scripting
here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb
cat dump.sql
INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies
9. Shell Programming and Scripting
Hi,
Am trying to count the number of occurrences and then as a percentage from a log to troubleshoot errors, can someone help please
grep -o 'HTTP/1\.1\" 404 3..' access_log | wc -l
6 (5 Replies)
Discussion started by: dmccabe
5 Replies
10. Shell Programming and Scripting
I have a large dataset with following structure;
C 0001 Carbon
D SAR001 methane
D SAR002 ethane
D SAR003 propane
D SAR004 butane
D SAR005 pentane
C 0002 Hydrogen
C 0003 Nitrogen
C 0004 Oxygen
D SAR011 ozone
D SAR012 super oxide
C 0005 Sulphur
D SAR013... (3 Replies)
Discussion started by: Syeda Sumayya
3 Replies
LEARN ABOUT PHP
xattr_set
XATTR_SET(3) 1 XATTR_SET(3)
xattr_set - Set an extended attribute
SYNOPSIS
bool xattr_set (string $filename, string $name, string $value, [int $flags])
DESCRIPTION
This function sets the value of an extended attribute of a file.
Extended attributes have two different namespaces: user and root. The user namespace is available to all users, while the root namespace is
available only to users with root privileges. xattr operates on the user namespace by default, but this can be changed with the $flags
parameter.
PARAMETERS
o $filename
- The file in which we set the attribute.
o $name
- The name of the extended attribute. This attribute will be created if it doesn't exist or replaced otherwise. You can change
this behaviour by using the $flags parameter.
o $value
- The value of the attribute.
o $flags
-
Supported xattr flags
+-----------------+---------------------------------------------------+
| | |
| XATTR_CREATE | |
| | |
| | Function will fail if extended attribute already |
| | exists. |
| | |
| | |
| XATTR_REPLACE | |
| | |
| | Function will fail if extended attribute doesn't |
| | exist. |
| | |
| | |
|XATTR_DONTFOLLOW | |
| | |
| | Do not follow the symbolic link but operate on |
| | symbolic link itself. |
| | |
| | |
| XATTR_ROOT | |
| | |
| | Set attribute in root (trusted) namespace. |
| | Requires root privileges. |
| | |
+-----------------+---------------------------------------------------+
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
Sets extended attributes on .wav file
<?php
$file = 'my_favourite_song.wav';
xattr_set($file, 'Artist', 'Someone');
xattr_set($file, 'My ranking', 'Good');
xattr_set($file, 'Listen count', '34');
/* ... other code ... */
printf("You've played this song %d times", xattr_get($file, 'Listen count'));
?>
SEE ALSO
xattr_get(3), xattr_remove(3).
PHP Documentation Group XATTR_SET(3)