R
R
Resolut2021-10-19 20:31:40
bash
Resolut, 2021-10-19 20:31:40

Script with a condition, how to write it correctly?

a script that, depending on the passed value, does one of the actions.
tried like this, didn't work.. newbie in bash

#!/bin/bash

value=$1
if "$value" = "one"; then
#действие 1
else
#действие 2
fi

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AVKor, 2021-10-19
@lxst

#!/usr/bin/env bash

value=$1
if [ "$value" = "one" ]; then
  echo "one!"
else
  echo "not one!"
fi

X
xotkot, 2021-10-19
@xotkot

https://devhints.io/bash#conditionals

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question