I am new to writing in bash and I just finished this long script but I made the mistake of not adding quotation marks to all the variables beginning with the unary operator $
. Adding all the quotation marks by hand is going to take a while. Is there a short cut I can use so all the words in the text file beginning with $
get quotation marks around them? So if a line in the file looks like:
python myProgram.py $car1 $car2 $speed1 $speed2
Then after the shortcut it will appear as
python myProgram.py "$car1" "$car2" "$speed1" "$speed2"
I am writing the script using nano.
Use global search and replace with the expression (\$\w+)
.
C-\
.Alt-R
.(\$\w+)
. Hit Enter."\1"
replace the captured expression with quotations. Hit Enter.A
for All.