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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 04-21-2009
Calypso Calypso is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 29
Loop through found files

Hi I am trying to write a script which will loop through all files that end in ".txt" and ask user if they want to delete the file or not

Code:
#this print out all files
dir=/root/etc/
find $dir -name "*.txt"
output:
1.txt
2.txt
etc

but what i really want is

1.txt delete(Y/N):
2.txt delete(Y/N):
etc


I have tried loops for example

Code:
for file $dir in "*.txt"; do
   echo "$file    delete (y/n)"
done
but they dont seem to be working, any ideas are very much appreciated thanks