![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| read user input from within a wile loop that is being fed from below | broli | UNIX for Dummies Questions & Answers | 2 | 01-09-2008 03:19 PM |
| Apply Regex to input read | bonekrusher | UNIX for Dummies Questions & Answers | 3 | 09-23-2007 02:45 PM |
| read input file for batch job | kinmak | Shell Programming and Scripting | 14 | 07-11-2007 07:22 AM |
| While read loop and rsh | 104234 | UNIX for Advanced & Expert Users | 1 | 01-15-2006 11:53 AM |
| input inside while read loop | jhansrod | Shell Programming and Scripting | 3 | 08-13-2005 10:46 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hi,
It's my first time on here, so hello everybody! Okay, the above message description probably makes no kind of sense so I'll just chuck the code down and explain the problem: Here's the offending bit of code. Basically it is intended to go through all the files in a directory and ask the user if he wants to delete them or not. ######################################## ls | \ while read LINE do echo "Line is $LINE. Delete (y/n)?" read ANSWER echo "Answer is $ANSWER" done ######################################### I am trying this out on a directory that has 2 files in it, file1 and file2. Here is the output: Line is file1. Delete (y/n)? Answer is file2 Then the loop exits. So when "ANSWER" is read what is actually happening is that the second item of the WHILE loop (file2) is being read into ANSWER and then, because there is nothing left for the while loop to loop through at that point, the loop is exited. I want the loop to stop and wait for my input (y or n) and only then continue. Any ideas anyone? I'm guessing the answer is something simple, I am quite new to UNIX, so this no doubt a schoolboy error of some sort. |
|
||||
|
Hey Shell Life,
Thanks very much for your response! It works! I don't know why it works, though. If you have the time to explain it, I would really appreciate that. Thanks for the tip! D |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|