Artificial intelligent assistant

How can a script ask me questions? I am using this script to analyse data: #!/bin/bash in=/autofs/cluster/transcend/mega/scripts/ insub=/autofs/cluster/transcend/mega/dtn/20141015/123 out=/autofs/cluster/transcend/mega/scripts/1256 for i in $(cat $in/list_subjects.txt); do echo "$i" mkdir ${insub}/${i}/file.nii.gz -k ${insub}/${i}/rh.nii.gz -M wait done How can this script ask me at the begining of it is work to confirm or change the paths in (in, insub and out)?

Try this. And play around with it a bit.


echo -n "Press enter to use \"$in\" or enter a new value: "
read userInput
if [[ -n "$userInput" ]]
then
in=$userInput
fi
echo ... I will use $in.


Error-checking (`test -d`, etc.) is up to you....

`read` is a bash builtin, so you can get help for it with the command `help read` (watch out, because you'll probably get results for both `read` and `readarray`, so be careful which help text you're _read_ ing). Reading the help will show you additional options, like the ones @Costas suggests using:


read -i $in -p "Press enter to use \"$in\" or enter a new value: " in

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 2eae92cd1c87c0c26280007689bcd4b9