The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to get files with a specific extension janavenki Shell Programming and Scripting 9 11-27-2007 04:56 PM
Feedback: Allow tar.gz extension for files DukeNuke2 Post Here to Contact Site Administrators and Moderators 2 08-29-2007 10:22 AM
Removing the extension and FTP the files pradkumar Shell Programming and Scripting 1 02-14-2007 10:01 AM
replace *.sqc files with *.sqC extension rameshonline Shell Programming and Scripting 6 04-28-2004 09:27 AM
How to list files will no extension Wing m. Cheng UNIX for Dummies Questions & Answers 5 02-21-2002 10:34 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-09-2002
Registered User
 

Join Date: Oct 2001
Location: Bangalore
Posts: 93
Stumble this Post!
How to test for files with a particular extension.

Hi!!,
Is there any way on Ksh to test the files having a particular Extension?

My program looks something like:

for i in *$1*
do
if "$i" != files with ext of .Z
then
compress -f $i
fi
done

Any suggestions???
Forum Sponsor
  #2 (permalink)  
Old 05-09-2002
Registered User
 

Join Date: Mar 2002
Location: London, England
Posts: 262
Stumble this Post!
compress script

you could replace the high lighted bit with

if ["$1" != *.Z]

or

replaced the entire script with

find (directory name) ! -name *.Z -exec compress -f {} \;

Note

using the find command will compress any file that is not compress in the specified directory.

make sure you specify the right directory and do not specify the root directory.

for example
to compress any file in /var/log directory
the syntax will be

find /var/log ! -name *.Z -exec compress -f {} \;

warning: do no spacify the root directory, only use the find command for log directory
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:55 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0