User Tools

Site Tools


assignments:2018bashassignment6

BASH Assignment 6

Question 1

Suppose I have a variable containing several words:

list="one two three four five"

Without changing the list, write a loop that only prints the following:

one
two
three

:!: Hint: write a script and test it. You may give me a whole script or just the loop.

Question 2

Given I have two files in my directory file_arg1 and file_arg2, where file_arg1 is executable (has been granted executable permission with chmod) and file_arg2 is not executable, write a script is_executable that will give the following output:

$ ./is_executable file_arg1
file_arg1 is executable
$ ./is_executable file_arg2
file_arg2 is NOT executable

:!: Hint: created those two files, and make one executable as we have in class. Write your script and test it on them.

:!: Hint: use the examples in class and/or this reference

assignments/2018bashassignment6.txt · Last modified: 2018/09/07 11:37 by david