The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
If Then Else Logic jadionne UNIX for Dummies Questions & Answers 7 11-23-2007 04:27 AM
expand logic for > and < pbsrinivas Shell Programming and Scripting 0 08-10-2007 09:59 AM
Strange Logic ganesh123 Shell Programming and Scripting 5 03-20-2007 05:08 PM
Need help in genrating the logic amitjha Shell Programming and Scripting 6 11-08-2006 06:45 AM
what the logic ramneek IP Networking 2 09-05-2005 07:42 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-11-2007
dineshr85 dineshr85 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 23
cannot get the logic

there is a folder with files having two extensions . eg: A.dat and A.cv ,B.dat & B.cv etc . i want to delete files like X.cv , Y.cv because X.dat and Y.dat is not there . tell me a script for this .
  #2 (permalink)  
Old 10-11-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Perhaps this.
Code:
for file in /dir/to/search/*.cv
do
  name=${file%.cv}.dat
  if [[ ! -f ${name} ]] ; then
    /bin/rm $file
  fi;
done

Last edited by vino; 10-11-2007 at 07:32 AM..
  #3 (permalink)  
Old 10-11-2007
thestevew thestevew is offline
Registered User
  
 

Join Date: Mar 2006
Location: South Yorkshire, UK
Posts: 114
Try
Code:
for file in *.cv
do
  if [ ! -f $(basename $file .cv).dat ]; then
    rm $file
  fi
done
  #4 (permalink)  
Old 10-11-2007
dineshr85 dineshr85 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 23
can u please explain the if condition that u guys have written
Sponsored Links
Closed Thread

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 03:07 AM.


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