sed hanging


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed hanging
# 1  
Old 01-16-2013
sed hanging

Code:
/bin/sed -n '$q;5633653,0 p' lfile

lfile is a log file that is being updated several times a second.

so, the command above figures out the line number it wants in the lfile and then proceeds to output all lines from that line number to the end of the file.

the problem is, the end of the file is not known because, as i said, the log file gets updated with many more lines every second.

so if the sed command figures out there are 5650000 lines in lfile right now, when it starts running the above command, and while running it, there are no longer 5650000 lines anymore in the lfile. that number has increased. so the sed command hangs.

is there a better way to run the above command?
# 2  
Old 01-16-2013
try:
Code:
sed -n ''$line',$p' lfile

Where $line is line number to start to print.
This User Gave Thanks to rdrtx1 For This Post:
# 3  
Old 01-17-2013
Wouldn't tail -f (-F)do that job - and better - for you?
This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sftp hanging

Hi All, I am transfering a file through sftp. But the script is hanging at exit occasionally. I am suspecting that sftp is hanging due to buffer size issue. If that is the case can any body suggest a solution. Please find the code. echo "cd /${CUST_ID}/inbound/${SAFET_ID}" >... (0 Replies)
Discussion started by: Girish19
0 Replies

2. UNIX for Dummies Questions & Answers

netstat -a is hanging??

Hi, I am on Solaris 10 server. I wanted to see a port is ESTABLISHED or in the LISTEN mode. But when I do netstat -a |grep 22205, it's hanging. I have waited over two minutes. Is it possible, something else is wrong on the server? I don't see anything on /var/adm/messages file. ... (3 Replies)
Discussion started by: samnyc
3 Replies

3. Shell Programming and Scripting

nslookup hanging

Hey folks. Long time lurker, first time poster. I'm a bit of a newbie at "coding" (obviously, scripting is a teensy bit different than coding) and I've run into a problem that I just can't seem to get around. I'm going through a list of servers to check their name, IP, reverse-NSLOOKUP name and... (2 Replies)
Discussion started by: Bearwhale
2 Replies

4. UNIX for Dummies Questions & Answers

Process Hanging

Hi! I have written a program three threads will be created to execute three different Sybase SQLs. so three thread will call a method runQuery. In run query again we create child process to execute the actuall SQL by connecting to the SQL. When I run the process first three threading working fine.... (0 Replies)
Discussion started by: jramesh1
0 Replies

5. Shell Programming and Scripting

script hanging???

ok... this is where i am at... i need a script to call another script as a wrapper because the first script creates a sub-shell. here is what i got... i kick off the first script "CCBDEMO-threadpoolworker.sh" #!/bin/bash clear #clearing screen directory="/data1/spl/cis/CCBDEMO/bin"... (1 Reply)
Discussion started by: Dagaswolf
1 Replies

6. Shell Programming and Scripting

Script is hanging

Hello, I have the following shell script and when i execute, it keeps hanging and nothing happens Please let me know. Requirement is to read data from file and pass it to the sql and create files as shown. code /******** #!/bin/sh while read user.dat do echo "user = $1 email =... (1 Reply)
Discussion started by: rakeshsr12
1 Replies

7. UNIX for Dummies Questions & Answers

Hanging port?

Ok, this question my be different. I can ping our unix box, but when we I to access the webpage I cant. To access the webpage I type http://ipaddress:some port. How do I check if a port is hanging and how would I un hang it. Sorry if question doesnt make sense. (1 Reply)
Discussion started by: NycUnxer
1 Replies

8. UNIX for Dummies Questions & Answers

Hanging commands

Hello, I just tried to run this command: /usr/lib/sendmail -d0.1 -bt < /dev/null | grep -i version Its doing what I want: writing out the sendmail version. But on some machines it writing the version and then exit to the prompt but on others its writing the version but then hangs, I need to... (0 Replies)
Discussion started by: jOOc
0 Replies

9. UNIX for Dummies Questions & Answers

ps command is hanging

Hi All, I am unable to figure out why my ps command is haning. Is some one else is running a process which is hanged. But in that case also if i do ps it should show only the processes running by me only. Thanks & Regards Gauri Agrawal (2 Replies)
Discussion started by: gauri
2 Replies

10. Programming

mq_open Hanging

One of my program which uses posix message queues was hanging in mq_open() system call, and after some time, it threw an error "Interrupted system call". I couldnt even unlink that message queue using mq_unlink(), as I have to use mq_open() prior to mq_unlink(). I use SunOS 5.7 Generic_106541-22... (0 Replies)
Discussion started by: Deepa
0 Replies
Login or Register to Ask a Question