cannot get the logic


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cannot get the logic
# 1  
Old 10-11-2007
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  
Old 10-11-2007
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 08:32 AM..
# 3  
Old 10-11-2007
Try
Code:
for file in *.cv
do
  if [ ! -f $(basename $file .cv).dat ]; then
    rm $file
  fi
done

# 4  
Old 10-11-2007
can u please explain the if condition that u guys have written
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need help in logic

I have big large snapshot file which contains every process start time and end time. One server snapshot contains many Application handle. My task is to identify the process id for which the end time is not there or empty also if the completion time is not on the same date then I need to kill. ... (6 Replies)
Discussion started by: senthilkumar_ak
6 Replies
Login or Register to Ask a Question