LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-03-2014, 07:05 PM   #1
sumncguy
Member
 
Registered: Jun 2013
Posts: 76

Rep: Reputation: Disabled
Bash/Sed : Long time (seconds) between print of last line and script termination


This snip works but there is a long lag time between the last line printed and the termination of the script. I set x but that didnt show me anything. Im wondering why this is happening.

Code:
grep -E 'tcp.*ssh|tcp.*telnet|udp.*snmp|Host is|scan report' fileone | sed -n "/^Nmap.*)$/,/^161/p" zee |\
sed '
s/\(SNMP.*\|OpenSSH.*$\|protocol.*\)//g;
s/^Nmap.*for //g;
s/Host is //g;
s/(.*latency.*$//g;
s/\(.*cp  \|.*dp \)//g;
s/\((\|)\)//g;
s/ *$//g' | tr '\012' ',' | sed 's/snmp,/snmp\n/g'
 
Old 11-03-2014, 11:16 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Arch
Posts: 10,021

Rep: Reputation: 3199Reputation: 3199Reputation: 3199Reputation: 3199Reputation: 3199Reputation: 3199Reputation: 3199Reputation: 3199Reputation: 3199Reputation: 3199Reputation: 3199
Well I am not sure I follow the process??

You are grepping certain regexes and then asking sed to read both from standard input and the file 'zee'. Is this desired?

As for the delay, one possible reason may be the size of the data being processed. Remember that sed is a stream editor so it processes the entire
stream as it is received. So if the last line which provides data is within the first few of millions of lines, it could take a while to finish.

---------- Post added 04-11-14 at 13:17 ----------

Well I am not sure I follow the process??

You are grepping certain regexes and then asking sed to read both from standard input and the file 'zee'. Is this desired?

As for the delay, one possible reason may be the size of the data being processed. Remember that sed is a stream editor so it processes the entire
stream as it is received. So if the last line which provides data is within the first few of millions of lines, it could take a while to finish.
 
1 members found this post helpful.
Old 11-04-2014, 07:04 AM   #3
sumncguy
Member
 
Registered: Jun 2013
Posts: 76

Original Poster
Rep: Reputation: Disabled
Tsch .. embarrassing ... But yes I do see that. Gotta remember to "keep it simple stupid"

thanks for the second eyeball.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sed: Not working as expected. Search out one line, print next line sumncguy Programming 2 10-02-2013 03:21 PM
[SOLVED] sed/awk to print every before line that pattern match niharikaananth Linux - Newbie 10 02-22-2012 10:47 PM
[SOLVED] Sed - print line number along with the line ? ntpntp Linux - Newbie 6 01-30-2011 05:58 AM
Bash: how to get time (in seconds) elapsed since creation of a file? J_Szucs Linux - General 6 12-27-2008 11:28 PM
bash script for displaying a file one line at a time. panchosansa Programming 6 10-12-2006 10:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration