changing permissions of a file whos name was passed to 755

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

  1. The problem statement, all variables and given/known data:

Write a shell script that gives a passed file the "755" access permissions. The shell script should:
Change permissions of the file whose name was passed to 755
The shell script should display a message that the named file (name to be displayed inside ") access change was made.
The shell script should output the result of the ls -l command for that file only.

Modify the script above so that it assigns a passed file a set of passed access permissions

  1. Relevant commands, code, scripts, algorithms:

  2. The attempts at a solution (include all code and scripts):
    I am just unsure of what this is asking, I think I am making it more complicated than it is. I know how to change permissions using the chmod command but I always have done this from the command line. I also cant get the quoting part correct. i did :
    "ls -l */755.*"
    echo ""
    is this wrong?

  3. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
    Sage College, Albany NY, USA, Leroy, CSI221 Linux for Net. Admin.

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Some clues to get you started.

If an executable script called "myscript" was invoked from the command line as

./myscript myfilename 755

we can save the parameters into named environment variables called say filename from $1 and the permissions parameter (755) from $2.

filename="$1"
echo "The first parameter is: ${filename}"
perms="$2"
echo "The second parameter is: ${perms}"

If we want to find out the current directory listing for the file myfile we can extend the script by one line. Any line starting with a hash character (#) a comment line and will be ignored by the shell.

filename="$1"
echo "The first parameter is: ${filename}"
perms="$2"
echo "The second parameter is: ${perms}"
# Directory listing for file called myfile
ls -la "${filename}"

Now we understand script parameters, we can take the saved $2 (now called ${perms} ) and substitute it into a unix chmod command.

Your turn!

Thank you so much, I was just making it harder on myself- I never set variables, so it was coming out terribly messy. I can take it from here- thank you for shining a light for me! I'm a newbie.

Good luck anix007 and welcome to our world.

I guess this would be considered and "Open Resource" ?

This forum is the legacy of DECUS (1961) and similar parallel strong root forums who acknowledge that System Administrators and System Programmers often work alone but are part of a powerful global community.