Sponsored Content
Top Forums Shell Programming and Scripting Grep for the same occurrence or maybe Sed Post 28046 by Optimus_P on Wednesday 11th of September 2002 06:42:18 PM
Old 09-11-2002
Quote:
Originally posted by photon
grep will not do it, because you need to store values.

Try Perl.

This code should print output such as.

Line: 344 Content: dasdjasdjoasjdoasjdoa SYN dakspodkapsdka
Line: 345 Content:asdasdasdasdasdasdasd SYN sdfsdfsdfsdfdf
Line: 346 Content:asdasdasdasdasdasdasd SYN sdfsdfsdfsdfdf
Dude, you have 3 lines!

just a couple of comments on the code if you dont mind.

1) dont use html. (unless you want to display it on a web page. in that case i would opt to make it a cgi and be able to run it on demand via the web.
2) the code as is does not work. your missing a double quote and a semicolon.
3) you will only get lines 1,2,3 not 4,5,6 and so on down the file. just an FYI. remember your resetting $count almost everytime.
4) instead of $count == 3 its prolly better to do a catch and and say ($count => 3) you never know if there can be more then 3.
5) remove the first print. so only the >=3 SYN lines print.

other wise pretty cool man. niCe job.

*Perderabo is my ksh hero
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using sed to substitute first occurrence

I am trying to get rid of some ending tags but I run into some problems. Ex. How are you?</EndTag><Begin>It is fine.</Begin><New> Just about I am trying to get rid of the ending tags, starts with </ and ending with >. (which is </EndTag> and </Begin>) I tried the following sed... (2 Replies)
Discussion started by: quixoticking11
2 Replies

2. UNIX for Dummies Questions & Answers

grep usage - exit after first occurrence

Hi, Is there any way of using grep (this may be done in awk, not sure?) that I can stop grep'n a file once I have found the first occurrence of my search string. Looking through grep man pages -q will exit without printing the lines after the first match, but I need the output. I have... (5 Replies)
Discussion started by: nhatch
5 Replies

3. UNIX for Dummies Questions & Answers

Line number of an occurrence using grep

Hi All, is there a way to extract the line number of an occurrence using grep? I know that with the -n option it prints out the line number as well. I would like to assign the line number to a variable. Thanks, Sarah (5 Replies)
Discussion started by: f_o_555
5 Replies

4. UNIX for Dummies Questions & Answers

grep first occurrence but continue to next entry in patternfile

I have 1300 files (SearchFiles0001.txt, SearchFiles0002.txt, etc.) , each with 650,000 lines, tab-delimited data. I have a pattern file, with about 1000 lines with a single word. Each single word is found in the 1300 files once. If I grep -f PatternFile.txt SearchFiles*.txt >OutputFile.txt... (2 Replies)
Discussion started by: newhavendweeb
2 Replies

5. UNIX Desktop Questions & Answers

grep a specific amount of occurrence

hey , i m trying to figure out how to do the following : i got a text file the looks like so: 1031 1031 1031 1031 1031 1031 1031 1031 16500 16500 16500 16500 1031 1031 (4 Replies)
Discussion started by: boaz733
4 Replies

6. Shell Programming and Scripting

Modifying sed to only change last occurrence.

I'm using sed to switch integers (one or more digits) to the other side of the ':' colon. For example: "47593:23421" would then be "23421:47593". The way it functions right now, it is messing my settings file to use with gnuplot. The current command is: sed 's/\(*\):\(*\)/\2:\1/' out3 >... (3 Replies)
Discussion started by: D2K
3 Replies

7. UNIX for Dummies Questions & Answers

Sed, last occurrence

How to find last occurrence of a keyword in a file using sed. (4 Replies)
Discussion started by: nexional
4 Replies

8. UNIX for Dummies Questions & Answers

Substitution in first occurrence with sed

I have the following script: sed '/string1/,/string2/!d' infile I want to apply the script to the first occurrence only. I have tried sed '0,/string1/,/string2/!d' infile Of course, that does not work Any help will be greatly appreciated (12 Replies)
Discussion started by: Xterra
12 Replies

9. Shell Programming and Scripting

sed print from last occurrence match until the end of last occurrence match

Hi, i have file file.txt with data like: START 03:11:30 a 03:11:40 b END START 03:13:30 eee 03:13:35 fff END jjjjjjjjjjjjjjjjjjjjj START 03:14:30 eee 03:15:30 fff END ggggggggggg iiiiiiiiiiiiiiiiiiiiiiiii I want the below output START (13 Replies)
Discussion started by: Jyotshna
13 Replies

10. Shell Programming and Scripting

Grep util last occurrence

I have file contents /tmp/x/abc.txt /home/bin/backup/sys/a.log I need this output: /tmp/x/ /home/bin/backup/sys/ Can somebody please help me out Please use CODE tags as required by forum rules! (3 Replies)
Discussion started by: jhonnyrip
3 Replies
synos(1)                                                        Mail Avenger 0.8.3                                                        synos(1)

NAME
synos - guess operating system from TCP SYN fingerprint SYNOPSIS
synos [--mtu mtu] [--db path] syn-fingerprint DESCRIPTION
synos takes a SYN fingerprint, in the format described for the CLIENT_SYNFP environment variable in the avenger(1) man page, and outputs a guess as to the type of the client operating system. synos makes use of the OpenBSD SYN fingerprint database (which is also repackaged with Mail Avenger). OPTIONS --mtu val Certain operating systems set the initial TCP window size based on the maximum transmission unit, or MTU, of the network. For such operating systems, synos usually checks the window size using both the client's MSS option plus 40 bytes (for TCP and IP headers), or a hard-coded MTU, which defaults to 1,500 bytes. If either value works, the fingerprint is considered to match the operating system. You can change the value 1,500 by specifying this option. A value of 0 tells synos to use only the value derived from the MSS option. --db file Specifies an alternate location for the SYN fingerprint database. FILES
/usr/local/share/pf.os Default location of SYN fingerprint database. SEE ALSO
avenger(1), asmtpd(8) The Mail Avenger home page: <http://www.mailavenger.org/>. The OpenBSD home page: <http://www.openbsd.org/>. BUGS
The operating system type is determined by heuristics that are not always reliable. Moreover, not all operating systems can be distinguished. The database may not even contain a client's particular operating system and version. It is not hard to fool synos deliberately by changing TCP socket options or injecting raw packets onto the network. AUTHOR
David Mazieres Mail Avenger 0.8.3 2012-04-05 synos(1)
All times are GMT -4. The time now is 10:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy