How do I prompt for Yes/No/Cancel input in a Linux shell script?

后端 未结 30 2305
不思量自难忘°
不思量自难忘° 2020-11-22 04:52

I want to pause input in a shell script, and prompt the user for choices.
The standard Yes, No, or Cancel type question.
How d

30条回答
  •  星月不相逢
    2020-11-22 05:18

    One simple way to do this is with xargs -p or gnu parallel --interactive.

    I like the behavior of xargs a little better for this because it executes each command immediately after the prompt like other interactive unix commands, rather than collecting the yesses to run at the end. (You can Ctrl-C after you get through the ones you wanted.)

    e.g.,

    echo *.xml | xargs -p -n 1 -J {} mv {} backup/
    

提交回复
热议问题