Skip to main content

One solution is Witwith the the builtin readread command.

 read -r -p 'Please enter your favorite editor' editor echo "You have enter $editor" 

Now the value is in the "$editor"$editor" variable, next step would be to test if there is indeed an editor that is installed or within your PATH.

if type "$editor" >/dev/null 2>&1; then command "$editor" ENTER_THE_FILE_YOU_WANT_TO_EDIT else echo "$editor no such file or directory!" >&2 exit 127 fi 

see

help type help command 

The 127 exit status is what the shell will exit if there is no executable, alias, function. have a look at

 man 1p exit 

One solution is Wit the the builtin read command.

 read -r -p 'Please enter your favorite editor' editor echo "You have enter $editor" 

Now the value is in the "$editor" variable, next step would be to test if there is indeed an editor that is installed or within your PATH.

if type "$editor" >/dev/null 2>&1; then command "$editor" ENTER_THE_FILE_YOU_WANT_TO_EDIT else echo "$editor no such file or directory!" >&2 exit 127 fi 

see

help type help command 

The 127 exit status is what the shell will exit if there is no executable, alias, function. have a look at

 man 1p exit 

One solution is with the the builtin read command.

 read -r -p 'Please enter your favorite editor' editor echo "You have enter $editor" 

Now the value is in the $editor" variable, next step would be to test if there is indeed an editor that is installed or within your PATH.

if type "$editor" >/dev/null 2>&1; then command "$editor" ENTER_THE_FILE_YOU_WANT_TO_EDIT else echo "$editor no such file or directory!" >&2 exit 127 fi 

see

help type help command 

The 127 exit status is what the shell will exit if there is no executable, alias, function. have a look at

 man 1p exit 
Source Link
Jetchisel
  • 1.6k
  • 9
  • 12

One solution is Wit the the builtin read command.

 read -r -p 'Please enter your favorite editor' editor echo "You have enter $editor" 

Now the value is in the "$editor" variable, next step would be to test if there is indeed an editor that is installed or within your PATH.

if type "$editor" >/dev/null 2>&1; then command "$editor" ENTER_THE_FILE_YOU_WANT_TO_EDIT else echo "$editor no such file or directory!" >&2 exit 127 fi 

see

help type help command 

The 127 exit status is what the shell will exit if there is no executable, alias, function. have a look at

 man 1p exit