How do I look for user input from the keyboard in the bash shell? I was thinking this would just work,
int b;
scanf("%d", &b);
but it says
-bash: /Users/[name]/.bash_profile: line 17: syntax error near unexpected token `"%d",'
-bash: /Users/[name]/.bash_profile: line 17: `scanf("%d", &b);'
EDIT
backdoor() {
printf "\nAccess backdoor Mr. Fletcher?\n\n"
read -r b
if (( b == 1 )) ; then
printf "\nAccessing backdoor...\n\n"
fi
}
int bcan just be left out, as can the semicolons at endlines. I'd suggest starting from scratch with something like mywiki.wooledge.org/BashGuide rather than assuming that syntax from completely different languages will work for bash. - Charles Duffyprintfbuiltin! - Peter - Reinstate Monicascanfin bash. In fact, I came to this very page because I googled "bash scanf"; I am trying to parse a string with a minimal set of sub-processes. There sure is a host of even bash-built-in string manipulation functions which can be used instead of ascanf. It's also not quite clear how one would realize the by-reference semantics ofscanftarget variables. But still: Aprintfwithout ascanfis an obvious asymmetry :-). - Peter - Reinstate Monica