On my EC2 Linux server, I blindly ran chmod 777 at directory that it turns out I should not have. There are hundreds of files in there, and I'm not sure which ones need to go back to their original permissions. I have server with the exact same configurations. So I'm trying to run a shell script that outputs a chmod command for each file in the directory. The plan is that I'd then take the results and execute them in a shell script on the other machine.I want my output to look like this:sudo chmod ### /somefilepath/sudo chmod ### /somefilepath/My shell script right now looks like:#!/bin/shfor file in /opt/bitnami/**do  perm = $(stat --format '%a' $file)  echo 'sudo chmod $perm $file'doneIt errors on each file with perm not found. What am I doing wrong?I was able to fix this after the response below, final script is:#!/bin/shFILES=$(find /opt/bitnami/ -name '*')for file in $FILESdo  perm=$(stat --format '%a' $file)  echo sudo chmod $perm $filedone
Shell script that outputs chmod command for all files
shell script;echo;variable substitution