Visit Our UNIX and Linux User Community


Tail-alike display of new files in directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Tail-alike display of new files in directory
# 1  
Old 03-21-2002
Data Tail-alike display of new files in directory

The system I work on, produces several kinds of status-files in a single directory. I would like to be able to see the files as they are added to this directory.

I was wondering if it would be possible to get a "tail -f" alike view of the ls-command, in such a way that a newly added file is automagically added at the bottom.

The way we do it now, is with the command below, which we need to execute manually (which imho is not handy):

ls -l -rt|tail -20 (to view 20 last files)

And we do more "in depth" searches inside these files with:

ls -l -rt tail `grep -l searchstring *`

But it would be wonderful to just see the list "grow" since this way, it is much easier to recognize errormessages since these errormessages are fixed size, 645 bytes and easy to spot.

We use SunOS 5.7 with Bash 2.01.
# 2  
Old 03-21-2002
Linux provides a utility called "watch" which you could use to do this. Something like:

watch "ls -lrt | tail -5"

would give you a constantly updated list of the 5 most recently updated files. Unfortunately, I dont think this utility is included with Solaris. It is part of the procps package on Linux. You could try downloading it (http://procps.sourceforge.net/) and compiling for your architecture.
# 3  
Old 03-21-2002
I do remember watch now! Have not used it in quite some time. I run mostly FreeBSD, OpenBSD and Solaris nowadays and didn't even miss it (until now!)...
Quote:
I dont think this utility is included with Solaris.
I just checked, you're right, it's not included. Smilie
Quote:
You could try downloading it (http://procps.sourceforge.net/) and compiling for your architecture.
Even though I am root on this machine, I am not allowed to install any software on it. This is a mission critical system (almost the entire carbranche in The Netherlands would collapse if anything happened to it!).
Getting permission to install additional software on it would require a lot of people to agree with it and I don't think that will happen in the near future.

Thanks for the reply!
# 4  
Old 03-21-2002
A simple shell script alternative would be something like:

Code:
#!/bin/sh
while (true)
do
     ls -lrt | tail -5
     sleep 5
     clear
done

Unfortunately the output can getting annoying as it clears the screen every time. "watch" does not suffer the same problem.
# 5  
Old 03-22-2002
MySQL

This works great!
Thanks a lot!

Previous Thread | Next Thread
Test Your Knowledge in Computers #365
Difficulty: Medium
The original code for vi was written by Bill Joy in 1976.
True or False?

10 More Discussions You Might Find Interesting

1. Web Development

Apache2 does not display files inside directory

Hello, I have been running Ubuntu14.04 + apache2. 000-default.conf: <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Directory... (5 Replies)
Discussion started by: baris35
5 Replies

2. Shell Programming and Scripting

Joining multiple files tail on tail

I have 250 files that have 16 columns each - all numbered as follows stat.1000, stat.1001, stat.1002, stat.1003....stat.1250. I would like to join all 250 of them together tail by tail as follows. For example stat.1000 a b c d e f stat.1001 g h i j k l So that my output... (2 Replies)
Discussion started by: kayak
2 Replies

3. Shell Programming and Scripting

Compare 2 files which are not look alike

Hi, I have 2 files as seen below. File 1: apple#fruit carrot#vege orange#fruitFile 2: #list of fruits fruitlist : apple#fruit grape#fruit orange#fruit finish (3 Replies)
Discussion started by: jayadanabalan
3 Replies

4. Solaris

Display the number of files in a directory and recursively in each subdirectory

Display the number of files in a directory and recursively in each subdirectory To look something like below, for example /var 35 /var/tmp 56 /var/adm 46Any ideas how can we do this? Got a sun cluser global mount point which takes ages to mount everytime, need to understand... (5 Replies)
Discussion started by: jakerock
5 Replies

5. Solaris

Display the number of files in a directory and recursively in each subdirectory

Display the number of files in a directory and recursively in each subdirectory To look something like below, for example /var 35 /var/tmp 56 /var/adm 46 Any ideas how can we do this? :wall: (1 Reply)
Discussion started by: jakerock
1 Replies

6. Shell Programming and Scripting

bash script to display tail

Hi everyone, I'm trying to write a script to format a file using unix2dos. I want to output all but the first 14 lines in a file. Then I want to pipe this to unix2dos to convert the output to a file that's easily readable on windows. Here's what I have: export Lines=`wc -l < $1` export... (11 Replies)
Discussion started by: LuminalZero
11 Replies

7. UNIX Desktop Questions & Answers

how to display paths of files in a directory

hi guys does anyone know how to display the file paths of the files stored within a directory at the command terminal? e.g. if i have a directory called "home", how do i display the file paths of the files inside the directory? cheers (2 Replies)
Discussion started by: Villaman69
2 Replies

8. UNIX for Dummies Questions & Answers

Find files and display only directory list containing those files

I have a directory (and many sub dirs beneath) on AIX system, containing thousands of file. I'm looking to get a list of all directory containing "*.pdf" file. I know basic syntax of find command, but it gives me list of all pdf files, which numbers in thousands. All I need to know is, which... (4 Replies)
Discussion started by: r7p
4 Replies

9. Shell Programming and Scripting

tail display ....in perl

hi we have 3 servers and we have a script to monitor cpu usage of all 3 servers and writes into one file on one of the server where we monitor all those servers ( by doing tail -f filename ) so we decided to create script ( perl ) that will read values from this file and display it should be like... (2 Replies)
Discussion started by: zedex
2 Replies

10. UNIX for Dummies Questions & Answers

how to display line number for tail -f

Hi, Just wonder if there is any quick way to display line number when monitoring a log file with tail -f? (4 Replies)
Discussion started by: iengca
4 Replies

Featured Tech Videos