Answer the question
In order to leave comments, you need to log in
I can not understand what is the problem in the bash script?
There is a script
#/bin/bash
replace='\033[9m[-] $2\033[0m'
dir='~/todo.txt/'
commands=('add' 'done' 'remove' 'init' 'help')
if [$1 = commands[0][; then
echo '[-] $2' >> dir && cat dir
elif [$1 = commands[1]]; then
sed -i 's/[-] $2/$replace/' dir && cat dir
elif [$1 = commands[2]]; then
sed '/[-] $2/d' dir
elif ["$1" = commands[3]]; then
touch dir
else
echo "Bad arguments. Type todo help to check arguments list."
fi
Answer the question
In order to leave comments, you need to log in
This is a cap.
If you started learning scripts an hour ago, learn to write individual commands syntactically correctly, and not take a non-working piece of text from somewhere and not understand what's going on.
To get started, paste your script here and check the syntax of each line
https://www.shellcheck.net/
check which way the quotes are facing, whether you put the spaces correctly.
And in general, it’s easier to write to start
I can not understand what is the problem in the bash script?
I can't figure out what's going on and why it's not working.
I started learning bash scripts an hour ago.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question