![]() |
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 |
| gcd.sh script doesn't work... | kantze | Shell Programming and Scripting | 1 | 01-17-2008 09:46 PM |
| Modify Perl script to work with txt - Permissions script | joangopan | Shell Programming and Scripting | 1 | 09-12-2007 11:38 PM |
| My script does not work - could you pls help? | BearCheese | Shell Programming and Scripting | 1 | 06-29-2007 05:12 AM |
| Script doesn't work, but commands inside work | cheongww | UNIX for Dummies Questions & Answers | 2 | 11-14-2006 10:52 PM |
| sed script. How does it work? | billy5 | Shell Programming and Scripting | 2 | 09-02-2005 04:45 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Help can't get script to work how I need it to...
Hi thank you for anyone who responds.
Here is my script: Code:
for i in `ls -1 | grep $1 | grep $2`
do
x=`echo $i | sed 's/\.Sent/\.Done/g'`
echo mv $i DONE/$x
echo "Is this OK?"
read user_response
case $user_response in
"y"|"Y")
mv $i DONE/$x
echo mv $i DONE/$x;;
*)
echo "No changes made ...";;
esac
done
The list it grabs is more than one file. When i run this it asks me if "Is this OK?" for each file. I want it to just spit out the list then ask me, if I say yes, then i want it to move all the files it lists. Thank you!! Last edited by radoulov; 10-13-2008 at 03:07 PM.. Reason: added code tags |
|
||||
|
Ok so I changed it but after it asks me it only moved one file?
Should I not be using a case statement to perform the move? I am using it to ask the user if the list is correct. I thought that inside the case statement I should put what shoudl be carried out if the user says no. Sounds like maybe I shouldn't be using case or put that somewhere else in the script? I've very new so please bear with me. Thank you! Last edited by llsmr777; 10-13-2008 at 03:36 PM.. |
|
||||||
|
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
|
|
||||
|
Oh I'm sorry. I'm obviously clueless I know that!
here is my code Code:
for i in `ls -1 | grep $1 | grep $2`
do
x=`echo $i | sed 's/\.Sent/\.Done/g'`
echo mv $i DONE/$x
done
echo "Is this OK?"
read user_response
case $user_response in
"y"|"Y")
mv $i DONE/$x
echo moved $i to DONE/$x;;
*)
echo "No changes made ...";;
esac
Code:
for i in `ls -1 | grep $1 | grep $2` do x=`echo $i | sed 's/\.Sent/\.Done/g'` echo mv $i DONE/$x done And then outputing it to the screen Code:
echo "Is this OK?" read user_response Code:
case $user_response in
"y"|"Y")
for i in `ls -1 | grep $1 | grep $2`
do
x=`echo $i | sed 's/\.Sent/\.Done/g'`
mv $i DONE/$x;;
*)
echo "No changes made ...";;
esac
and to print to screen "No changes made" if the user says no When I run the script it lists all the files then asks me if it's ok when I hit Y And I do a listing only 1 of the files listed were moved not all. Thanks again. Last edited by llsmr777; 10-13-2008 at 04:47 PM.. |
| Sponsored Links | ||
|
|