Tail command with wildcard file name


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Tail command with wildcard file name
# 1  
Old 09-02-2010
Tail command with wildcard file name

Please help with the following command

tail -f /appdata/logs/alert_audit517.txt | grep "Sep 02"

The problem I have is with the file name "alert_audit517.txt". The 3 digit number at the end of the file name changes, so I need the file name to use a wildcard. Ive tried alert_audit***.txt, but thats not working. I also have other files in the directory that begin with the filename alert_audit, but do not end with a 3 digit number.

Thanks in advance for any help.
# 2  
Old 09-02-2010
Use ? instead of *
# 3  
Old 09-02-2010
? is not working either
# 4  
Old 09-02-2010
You could also do alert_audit[0-9][0-9][0-9].txt which would be guaranteed to only match ones with three-digit numbers. Remember to not put the name in quotes, it won't expand to match the filename if it's in quotes.
# 5  
Old 09-03-2010
Code:
tail -f /appdata/logs/alert_audit[0-9][0-9][0-9].txt | grep "Sep 02"

This will not allow for the filename changing during the run of "tail -f".
If that is going to happen we will need a more sophisticated log monitor which does not keep the log file open.
# 6  
Old 09-03-2010
GNU tail can open more then one file.

To have gnu tail you must install coreutills.

Last edited by john1212; 09-04-2010 at 05:40 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

How to display certain line of file only using head or tail in 1 command?

First month learning about the Linux terminal and it has been a challenge yet fun so far. We're learning by using a gameshell. I'm trying to display a certain line ( only allowed 1 command ) from a file only using the head or tail. I'm pretty about this answer: head -23 history.txt | tail -1... (1 Reply)
Discussion started by: forzatekk
1 Replies

2. UNIX for Beginners Questions & Answers

Tail -f Command help

Hi Team, Can anyone help me here: I have to access server logs via putty and these logs file is a trailing file (continously updating) with ERROR and WARNINGS... I need to know if I can pull this trailing file to a local drive so that I can do some higlighting on some keywords through Notepad... (13 Replies)
Discussion started by: jitensetia
13 Replies

3. Shell Programming and Scripting

How to process only new line of tail -f command from live log file?

Hi, I want to read a live log file line by line and considering those line which are newly added to file Below code I am using, which read line but as soon as it read new line from log file its starts processing from very first line of file. tail -F /logs/COMMON-ERROR.log | while read... (11 Replies)
Discussion started by: ketanraut
11 Replies

4. Shell Programming and Scripting

tail command help

Hi does anyone know how to create a file using the tail command? My book has this file I need to create and it says to use the tail command and that it is possible but I have no idea. Thanks. (4 Replies)
Discussion started by: drew211
4 Replies

5. Shell Programming and Scripting

Wildcard use with SED command

Hello, I am fairly new to Linux in general and I am trying to use SED to make some replacements in a file. Below is sample of what the file is like. <Grouping id="024"><Source>ABC</Source><GroupingKey>000000000816</GroupingKey></Grouping><Grouping... (9 Replies)
Discussion started by: runforfun7
9 Replies

6. Shell Programming and Scripting

find command with wildcard directory

I want to look if there is any file inside a specific directory which was modified before 2 days. I wrote the find command, but the problem is there is one directory and that is a random directory generated by unix, so not sure on how to code for that on the find command. find... (5 Replies)
Discussion started by: srini0603
5 Replies

7. Shell Programming and Scripting

Wildcard in Cshell find command

The following command works fine in my cshell script: set Deliverables = `find . -name "eliverables" -print` The following command does not work: set LASFiles = `find . -name "*." -print` In the first example, when tested in an if statement, the script will continue whether a... (3 Replies)
Discussion started by: phudgens
3 Replies

8. Linux

tail most recent file command

I have only been working with Linux for a few years now so bear with my noob question. I was wondering if there is a way to tail the most recent file that has a file name like 'scrubsncoa%'. There will be at least 2 files in the directory that start with 'scrubsncoa' and a few other different... (2 Replies)
Discussion started by: RyanD
2 Replies

9. Shell Programming and Scripting

tail command

Hi , I have found a interesting thing about tail command: when I tried to use 'tail -1 *' to look at every file with the current derectory, I only got one line of result of one file. But if I use 'head -1 *', I would get multiple lines. Is there a way to do get multiple lines with 'tail -1 *'... (3 Replies)
Discussion started by: whatisthis
3 Replies

10. UNIX for Dummies Questions & Answers

Find wildcard .shtml files in wildcard directories and removing them- How's it done?

I'm trying to figure out how to build a small shell script that will find old .shtml files in every /tgp/ directory on the server and delete them if they are older than 10 days... The structure of the paths are like this: /home/domains/www.domain2.com/tgp/ /home/domains/www.domain3.com/tgp/... (1 Reply)
Discussion started by: Neko
1 Replies
Login or Register to Ask a Question