Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use chmod inside a shell script

Tags:

shell

chmod

So this is in a shell script:

#!/bin/bash
trialName= "trial.txt"

chmod a+rwx $trialName

That doesn't really work. I am trying to add single quote/double quotes around $trialName but that doesn't work either. Any way I can do that?

like image 339
kakka1234 Avatar asked Sep 11 '25 14:09

kakka1234


1 Answers

You need to remove the space after the =:

trialName="trial.txt" # note the absence of the space between '=' and '"'
chmod a+rwx "$trialName"
like image 118
Tim Pote Avatar answered Sep 14 '25 19:09

Tim Pote