Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

If I wish to execute the commands ls;cat test;cp test testlocation for example, can I confirm the start of each command prior to it executing? If it is possible, how do I do so?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I'm assuming you mean that each command in sequence succeeded.

In that case, do this: ls && cat test && cp test testlocation


In response to the clarification:

Create a function called get_confirmation:

function get_confirmation() {
    echo -n "Continue? (Y/N) "
    read RESULT
    return $([ "$RESULT" = "Y" ])
}

Then do: ls && get_confirmation && cat test && get_confirmation && cp test testlocation

share|improve this answer
    
I mean if I execute the command ls, it first lists all the files and then asks me for confirmation if I would like to execute the next command. –  PeanutsMonkey Mar 4 '12 at 18:42
    
@PeanutsMonkey Thanks for the clarification - the edit addresses this. –  new123456 Mar 4 '12 at 18:50
    
Thanks new123456. Wasn't aware I could simply write a function to get the confirmation. Is that the only way? –  PeanutsMonkey Mar 4 '12 at 19:12
    
Would it be possible to email you more questions? Am a newbie at Linux and am having a hard time comprehending some of the fundamentals. –  PeanutsMonkey Mar 4 '12 at 19:14
    
@PeanutsMonkey As far as I know, bash has no inbuilt functionality to ask for confirmation - most every shell script will have some sort custom input function. Feel free to ask any questions here - you tend to get a very quick answer. –  new123456 Mar 4 '12 at 23:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.