The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Insert file names when concatenate files into a file samky2005 Shell Programming and Scripting 2 06-05-2009 07:07 PM
find for specific content in file in the directory and list only file names madhu_Jagarapu AIX 2 12-23-2008 02:13 AM
Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names nikosey Shell Programming and Scripting 6 07-30-2008 10:46 PM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 05:25 AM
File names giantflameeater UNIX for Dummies Questions & Answers 9 11-24-2004 07:03 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 3 Weeks Ago
suresh_kb211 suresh_kb211 is offline
Registered User
  
 

Join Date: May 2009
Posts: 28
Getting file names which does not end with .log

Hi All,
I have a directory in which all log files will be generated. Apart from the log files, there are a few other files also generated. I want the names of all files which does not end with .LOG.

consider the dir has the following files
Quote:
tbaf01012009.LOG
tbaf02012009.LOG
ebaf02012009.ERR
tbaf03012009.LOG
tbaf04012009.LOG
I want only ebaf02012009.ERR file.

Unix Experts, Please help. Thanks in advance.
  #2 (permalink)  
Old 3 Weeks Ago
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,434
Code:
ls | grep -v "LOG$"
  #3 (permalink)  
Old 3 Weeks Ago
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,184
The exclamation mark in "find" means not.

Code:
find /dir/ -type f ! -name \*\.LOG -print
If *.ERR is the only type you are interested in:

Code:
find /dir/ -type f -name \*\.ERR -print
  #4 (permalink)  
Old 3 Weeks Ago
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,554
Code:
ls *.[^L][^O][^G]
  #5 (permalink)  
Old 3 Weeks Ago
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,910
ksh, zsh and bash support extended globbing:

[ksh]

Code:
print !(*.LOG)
[bash]

Code:
shopt -s extglob
printf '%s\n' !(*.LOG)

[zsh]


Code:
print ^*.LOG
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:42 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0