Need to grep for .log files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to grep for .log files
# 1  
Old 04-24-2009
Need to grep for .log files

Hi,

Have two files.

1. robin.log
2. robin_log

When is grep i shuld get only robin.log file.

Please help.

I Tried ls | grep ".log" But its not working

Thanks
Robin
# 2  
Old 04-24-2009
Try.......

Code:
find . -name "*.log"

# 3  
Old 04-24-2009
Thanks a lot for your help..
its gives only .log files but it displays all the .log files which are in subdirectories also..

I need the files only in that directory..
# 4  
Old 04-24-2009
try this out
ls *.log
# 5  
Old 04-24-2009
Or....

Code:
find *.log

# 6  
Old 04-24-2009
you want to find the file or u want to short list the file in a directory with .log extension
# 7  
Old 04-24-2009
Quote:
Originally Posted by robinbannis
Hi,

Have two files.

1. robin.log
2. robin_log

When is grep i shuld get only robin.log file.

Please help.

I Tried ls | grep ".log" But its not working

Thanks
Robin

Hello,

If you are inside the directory and looking for *.log files no need to use grep, then use:

Code:
ls -lrt *.sh | awk '{print $NF}'

if you dont where you are and want to search for all *.log files from the scratch in your home directory, use:

Code:
find . -name *.log| sort +6nr | more

if you want only file names use:

Code:
find . -name *.log| sort +6nr| awk -F"/" '{print $NF}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirecting log files to null writing junk into log files

Redirecting log files to null writing junk into log files. i have log files which created from below command exec <processname> >$logfile but when it reaches some size i am redirecting to null while process is running like >$logfile manually but after that it writes some junk into... (7 Replies)
Discussion started by: greenworld123
7 Replies

2. Shell Programming and Scripting

Python - glob () - How to grep same files with different extension files

Hi I Have a directory and i have some files below abc.txt abc.gif gtee.txt ghod.pid umni.log unmi.tar How can use glob function to grep abc files , i have created a variable "text" and i assigned value as "abc", please suggest me how can we use glob.glob( ) to get the output as below... (2 Replies)
Discussion started by: kumar85shiv
2 Replies

3. Shell Programming and Scripting

Script to grep for a string in log files generated in last 15 minutes.

Dear Guru's I've a requirment to grep for a string in series of log files that are getting generated almost every minute. I'm looking to schedule a script every 15 mountes,in order to check if the error string has been generated in any of the log files generated in last 15 minutes. Please... (3 Replies)
Discussion started by: rajivatnova
3 Replies

4. Shell Programming and Scripting

Best way to connect to hundreds of nodes and grep log files

Hi, What will be the best way to connect (ssh) to hundreds of nodes and grep log files parallely from shell. Using for loop seems to be sequential. Are there any shell built in construct which could be used to achieve this? Is the sub shell any good here? (1 Reply)
Discussion started by: agent001
1 Replies

5. Shell Programming and Scripting

Grep all lines for a specific date in log-files

I need to grep all lines for "yesterday" in /var/log/messages. Dates are in the format "YYYY-MM-DD". (5 Replies)
Discussion started by: Padmanabhan
5 Replies

6. Shell Programming and Scripting

How can view log messages between two time frame from /var/log/message or any type of log files

How can view log messages between two time frame from /var/log/message or any type of log files. when logfiles are very big and especially many messages with in few minutes, I would like to display log messages between 5 minute interval. Could you pls give me the command? (1 Reply)
Discussion started by: johnveslin
1 Replies

7. Programming

Help to grep string in log files

hello guys.., i have some problem with grepping strings in log files.. so..,i need an java logic on how to grep srtings in log files the output must be in gui.., please help me .. regards raghuraipur:confused: (1 Reply)
Discussion started by: raghuraipur
1 Replies

8. Shell Programming and Scripting

special grep on log files... puzzling me.

Okay, guys, I've got one: I've got a script that formats all of the messages in a log file. It works on a completely verbose method. I'm trying to write a filter that will search for a bunch of case-insensitive strings, but also, always print the first 2 lines. Here's the egrep part: ... (4 Replies)
Discussion started by: quirkasaurus
4 Replies

9. Shell Programming and Scripting

grep for certain files using a file as input to grep and then move

Hi All, I need to grep few files which has words like the below in the file name , which i want to put it in a file and and grep for the files which contain these names and move it to a new directory , full file name -C20091210.1000-20091210.1100_SMGBSC3:1000... (2 Replies)
Discussion started by: anita07
2 Replies

10. UNIX for Dummies Questions & Answers

Constantly updating log files (tail -f? grep? awk?)

I have a log file which is continuously added to, called log.file. I'd like to monitor this file, and when certain lines are found, update some totals in another file. I've played around with tail -f, grep, and awk, but can't seem to hit the right note, so to speak. The lines I'm... (0 Replies)
Discussion started by: nortonloaf
0 Replies
Login or Register to Ask a Question