I'd like to run my script fastex with two possible arguments (g or t), like fastex g. Based on the argument I want to call geany $file or texstudio $file. This is to choose the editor.I triededitor=$1if [$1 = g]; thengeany $file.texexit 1elselinha=$(wc -l < $file.tex)texstudio --line $linha  $file.texexit 1fibut the outuput of fastex.sh g is /usr/bin/fastex.sh: 31: [g: not found and it always opens texstudio. The same if I pass t.
Script to choose editor to open file based on the argument
bash;scripting
You need space after if [ because [ is actually a command (like test) which reads it's arguments (it may be interpreted by the shell but it may be not). Using [[ makes sure shell's internal logic is used (faster, since no new process is launched). Although shells may interpret the [ and test as builtins, this feature can be turned off with enable (and then a new process really is launched).= is the comparison operator inside of conditional expressions (both external and builtin) however, it is also the assignment operator elsewhere. While test and = conform to POSIX, using == (recognized in [[) seems to be a reasonable choice whenever one doesn't aspire to POSIX conformance, since it brings a bit more sanity to the shell inconsistency of the context dependent meaning of =.exit 1 - why effectively discard editor's return value? Either leave it out completely or use exec to replace the script with the editor.#!/bin/basheditor=$1if [[ $1 == g ]]; then    exec geany $file.texelse    linha=$(wc -l < $file.tex)    exec texstudio --line $linha  $file.texfi