shanenin Posted May 23, 2005 Report Share Posted May 23, 2005 I was just messing around using a for loop. I would assume my for loop would work on every item in this substitution `ps -Ao comm`, it does not. As soon as I enter "yes" in my input, it executes the command echo $i, then stops. Why is it not looping until every item in `ps -Ao comm` has been used as a variable?#!/bin/bashfor i in $(ps -Ao comm)do echo "do you want to kill the following process [y/n], or enter [exit] to quit"echo $iread INcase $IN in[yY]|[yY][eE][sS]) exec echo $i;;[nN]|[nN][oO]) echo "continuing to next process";;exit) exit;;*) echo "process ignored, continuing to next";;esacdoneone more thing, the command "exec" seems useless. What purpose does it serve? Quote Link to post Share on other sites
shanenin Posted May 23, 2005 Author Report Share Posted May 23, 2005 (edited) the exec was my problem. I have this link that explains whyhttp://www.faqs.org/docs/abs/HTML/internal.html#EX54I guess it does serve a purpose :-) Edited May 23, 2005 by shanenin Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.