LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-24-2003, 10:18 PM   #1
dcoder
LQ Newbie
 
Registered: Aug 2003
Location: Valemount BC
Distribution: Mandrake 9.1 (desktop) Debian (server)
Posts: 10

Rep: Reputation: 0
Question tail -f


I am trying to shell comands and I tried tail -f and it does not work. Here is what I did

create a file called new
start a new session run tail -f new
go back to old session and echo new_line >> new
return to tail session to see if it prints out the addition to the file called new.


It just sits and runs. I even tried tail -f -s 1 new and it does not seem to make any difference

(Mandrake 9.1)

Thanks in advance for anyone who can help.
 
Old 08-24-2003, 11:24 PM   #2
Tarts
Member
 
Registered: Feb 2003
Distribution: Slackware 9.1 (exclusively) ;)
Posts: 344

Rep: Reputation: 30
Hi.
Code:
[Mirrus][stratus][11:26:11][~][$] > new.txt
[Mirrus][stratus][11:26:32][~][$] echo new_line > new.txt
[Mirrus][stratus][11:26:45][~][$] tail -n 1 new.txt
new_line
[Mirrus][stratus][11:26:56][~][$]
feel free to do anyway but mine. :)
{edit}
'man tail' 'man bash'...
The reason it hang's is because the file is less than 10 line's, which is why i specified 'tail -n 1', if it is less then 10 line's it will hang.

Last edited by Tarts; 08-25-2003 at 06:43 PM.
 
Old 08-25-2003, 08:14 AM   #3
yuray
Member
 
Registered: Apr 2003
Location: Russia, Khotkovo
Distribution: Debian
Posts: 146

Rep: Reputation: 15
On my machine it is work. [Debian]
I using two gnome-term.
 
Old 08-25-2003, 11:27 AM   #4
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 683

Rep: Reputation: 63
dunno if it helps or not but are you in the same directory with both files? (ie are you watching /home/foo/new in one and /tmp/new in another window?)
try it with full pathnames...
example:
touch /tmp/junk
tail -f /tmp/junk

in window two copy and paste this:
date >> /tmp/junk
sleep 5
date >> /tmp/junk
sleep 5
date >> /tmp/junk
sleep 5
date >> /tmp/junk
sleep 5

Last edited by Blinker_Fluid; 08-25-2003 at 11:29 AM.
 
Old 08-25-2003, 07:09 PM   #5
Tarts
Member
 
Registered: Feb 2003
Distribution: Slackware 9.1 (exclusively) ;)
Posts: 344

Rep: Reputation: 30
It work's with mine too...i think the problem he still has is it sitting and looping, in that case you would have to send a EOF (end of file), i don't know what that would be, i just used Ctrl-c. Where are you dcoder, tell if this helped at all.

Last edited by Tarts; 08-25-2003 at 07:11 PM.
 
Old 08-25-2003, 08:26 PM   #6
dcoder
LQ Newbie
 
Registered: Aug 2003
Location: Valemount BC
Distribution: Mandrake 9.1 (desktop) Debian (server)
Posts: 10

Original Poster
Rep: Reputation: 0
Hi everyone,
Thanks this helps. tail -fn 1 new.txt works and you are right my file had less than 10 lines in it. I was at work today (school) and I tried it on the debian box and it worked just fine there without the n switch.
again thanks for the help :-)
 
Old 08-25-2003, 08:52 PM   #7
Tarts
Member
 
Registered: Feb 2003
Distribution: Slackware 9.1 (exclusively) ;)
Posts: 344

Rep: Reputation: 30
Code:
dev/pts/1 >> new.txt & tail -f new.txt
of cource replace the '/dev/pts/x' with approprate , 'echo $(tty)'.
To terminate 'tail'... Ctrl-c.

Last edited by Tarts; 08-26-2003 at 12:07 AM.
 
Old 08-25-2003, 09:34 PM   #8
Tarts
Member
 
Registered: Feb 2003
Distribution: Slackware 9.1 (exclusively) ;)
Posts: 344

Rep: Reputation: 30
Quote:
Originally posted by dcoder
Hi everyone,
Thanks this helps. tail -fn 1 new.txt works and you are right my file had less than 10 lines in it. I was at work today (school) and I tried it on the debian box and it worked just fine there without the n switch.
again thanks for the help :-)
Then the file must have been bigger than 10 line's, hmmmm, can you show me the command you used on that box, the one at work that is.
see post #7, i think this is what you wanted, if not oh we'll, 3 hour's of fun to figure it out, and i learned from it too. :)
 
Old 09-01-2003, 08:41 PM   #9
dcoder
LQ Newbie
 
Registered: Aug 2003
Location: Valemount BC
Distribution: Mandrake 9.1 (desktop) Debian (server)
Posts: 10

Original Poster
Rep: Reputation: 0
Thumbs up

Hey, I thought this was dead.... thanks for keeping it up :-)
Here is what I just did.
-1 Started a new session and telnet'd into school
-2 Created a file called test.txt and typed in six lines like so
one
two
three
four....
-3 Started a second session and telnet's into school and typed the command tail -f text.txt
-4 Went back to the first session and typed echo seven >> text.txt.

Noticed in the second session that the word seven appeared.

The reason I have interest in this is that students are not allowed to use msn at school so if I tail squid.log and pipe it to grep to look for msn hmmm....;-)

thanks
 
  


Reply



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
root tail scylla Linux - Software 9 08-03-2005 04:44 PM
Coloured tail??? bram2000 Linux - Software 1 01-28-2005 11:42 AM
root-tail help! perry Linux - Software 3 07-25-2004 04:35 PM
root-tail -help Streams Linux - Software 2 04-26-2003 04:16 PM
how unsecure is tail -f WeNdeL Linux - Security 6 03-06-2003 03:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:28 PM.

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