Question: 4. Write a script which is passed a list of items (files, directories, links, etc) in the current directory as parameters. The script will iterate

 4. Write a script which is passed a list of items

4. Write a script which is passed a list of items (files, directories, links, etc) in the current directory as parameters. The script will iterate through this list, obtaining the long listing for each item and convert the permissions of the item into the 3-digit numeric equivalent. To accomplish this, you will have to store the permission portion in a variable. Assume the current filename is stored in the variable FILE. You can obtain the permissions using the following instruction permissions ls - SFILE awk print S1" The variable permissions will store the 11 characters in the permissions (the type of object, - for file, the 9 characters that make up the permissions, and a period that ends this sequence) You want to access characters 2-10. To access a single character, you can use notation like this S(permissions:INDEX:1 where INDEX is a number between 1 and 9 (recall that for this notation, the first character is at index 0). Now you want to look at the 3 sets of characters (1-3, 4-6, 7-9) and convert the r, w, and x into a value. You will need three separate sums, we can for instance call them first, second and third. If the character at index l is 'r', then add 4 to first, otherwise do nothing. If the character at index 2 is 'w', then add 2 to first, otherwise do nothing. And so forth. You might have if-then instructions that loolk like this: if Spermissions: 1:1r];then first S((first first+4)); fi

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!