LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 08:05 PM   #1
sumncguy
Member
 
Registered: Jun 2013
Posts: 71

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-04-2014, 12:16 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,255

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
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, 08:04 AM   #3
sumncguy
Member
 
Registered: Jun 2013
Posts: 71

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 04:21 PM
[SOLVED] sed/awk to print every before line that pattern match niharikaananth Linux - Newbie 10 02-22-2012 11:47 PM
[SOLVED] Sed - print line number along with the line ? ntpntp Linux - Newbie 6 01-30-2011 06:58 AM
Bash: how to get time (in seconds) elapsed since creation of a file? J_Szucs Linux - General 6 12-28-2008 12:28 AM
bash script for displaying a file one line at a time. panchosansa Programming 6 10-12-2006 11:54 AM


All times are GMT -5. The time now is 12:58 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration