Hi
I am new to unix and want to learn shell scripting.
Right now I am use cygwin for windows but sooner I will switch to ubantu.
So when I wrote my first script (just copied from the book I was reading), I came to know I have to give execute permission to the script file.
So now I want to create a script which will take the file as input and will just change the permissions such that It wont effect read/write permission but only grant the execute permissions.
So I tried to write something like this (code mixed with psuedocode is written below)
#GrantExPer
#Usage: GrantExPer <filename>
str1='ls -la ' #first string
str2=$1 # second string contains file name
echo $str2 # this works
comm1=$str1 $str2 #command1 by concatenating string 1 and string 2, this doesn't work for me
$comm1 #execute command1
var1=$1 #get output of the above command in some var1
#find out current permissions using var1 and calculate some integer $newPermission (which contains new permissions)
chmod $newPermission $str2 #str2 still contains file name I think
Please guide me for:
1. How to make a right command. I tried it by concatenate 2 strings. (line 4-7)
2. Then how to execute it. (line 8)
3. Is there any command which shows me file permissions in a number format like 644 rather than -rw-r--r--. To me number format seems easier to manipulate.
Thanks