N
N
nihi1ist2021-07-12 19:06:59
bash
nihi1ist, 2021-07-12 19:06:59

How to implement a value input as part of a parameter?

Tell me how to implement the construction when there is a yes / no condition during the script startup . And if the answer is yes - you will need to add a key and a custom value. If the answer is no - just continue the script execution. key "value". Where keyis a constant value, and value- is entered by the user after running the script. Separately, I know how to do it, but it's impossible to connect.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2021-07-12
@nihi1ist

It's not entirely clear what exactly doesn't work, but here's an example

#!/bin/bash

 echo "Yes or No?"
 read -p "Answer: " varanswer
 echo $varanswer
if [ "$varanswer" = "Yes" ]; then
    read -p "KEY: " varkey
    echo $varkey
else
    echo "do script"
fi

C
CityCat4, 2021-07-12
@CityCat4

Form the command line in pieces and assemble it from the pieces at startup.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question