Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Operating System Expert

1) Write a shell script called "lss" that will list all the files in the current directory in decreasing order of the number of bytes in the file.  It does not need to take any arguments. Ex:

$ lss          -rwxrwxr--    1 wayne   faculty      385 Nov 29  1996 lss     -rwxrwxr--    1 wayne   faculty       42 Mar  9  1990 nf

This was a previous assignment.

The "lss" command written in the previous assignment didn't take any arguments.  Re-write it so that it will work if given command line arguments. More specifically:    

(a) If given no arguments, "lss" should give a "ls -l" listing sorted by decreasing byte count.   

(b) It should accept as many of "ls"'s options as it can, and pass those options on to "ls".  But be careful; options like "-s", "-i", or "-g" may really foul up your sorting if you try to accept them.  It is OK to decide not to accept options like that, if you think it would be too hard, messy, or inefficient to support them. Any option not accepted should cause "lss" to print an error message and halt. (Document your decisions and reasons behind them.)  Note that if there are options, but no filenames, then it should work as in (a), but additionally with the options passed to "ls".

c) Any other arguments should be interpreted as filenames, and *only* those filenames listed should be processed. Directories should NOT be descended unless the files inside those directories are explicitly listed.    

(d) It should be as "bulletproof" as possible. It should either print the list in the required order, or fail gracefully.  THIS IS IMPORTANT. Here are some examples, executed in ~wayne/pub/ics54/a3.lss.dir    

$ ls -l    

total 2     drwxr-xr-x   2 wayne         512 Sep 25 23:58 dir

-rw-r--r--   1 wayne           3 Sep 25 23:59 file    

lrwxrwxrwx   1 wayne           4 Sep 25 23:58 symlink -> file    

$ lss

drwxr-xr-x   2 wayne         512 Sep 25 23:58 dir

2) Some people complain that Unix doesn't have an "un-delete" program.  Write a suite of shell scripts called "srm", "unrm", "lsrm", "durm", and "trash".  "srm" is a "safe" version of "rm" --- rather than actually removing files, it moves them to a safe place; "unrm" un-removes a file if it hasn't been trashed; and "trash" actually removes all files that are currently safe-rm'd, recovering the disk space. "lsrm" takes no arguments and performs "ls -l" on all files that are currently in the trash, and "durm" runs "du" on the trashcan to let you know how much disk space would be recovered by running "trash".  If "srm" is invoked with a directory, then the entire directory heirarchy should be safe-rm'd.  (But it's not necessary to be able to "unrm" individual files in asrm'd directory; being able to unrm the entire heirarchy, as a whole, is good enough.  In other words, you only need to be able to "unrm" names that were explicitly srm'd.)  Furthermore, if "srm" is called on a path, it is not necessary to remember the entire path; in that case, "unrm" should only work with the current directory.  If "srm" is called with any options, you may simply exec the regular /bin/rm.  "trash", "lsrm", and "durm" take no arguments.  Both "srm" and "unrm" may be called with many arguments, eg "srm *".  (But of course "unrm" won't usually be called with "*" --- why?)         

You should try to make them reasonably fast; if an "srm" takes too long, and you are the impatient type (as most programmers are), then you are unlikely to use it regularly.  Thus design is important.  Two obvious possible designs are: (1) have a single, global, safe-rm directory where all srm'd files go; (2) leave srm'd files in the directory in which they lived, but "hide" them somehow.  The design is up to you.  Your mark will depend good design and implementation decisions.  (It is possible to do a good job using either of the above suggested designs, or you can even think of an entirely new one if you want).  You should clearly document each design decision and reasons behind it, and what advantages and disadvantages it has compared to others.         

Some other things to think about: what do you do if "srm" is called on a filename that is already srm'd?  Does the old srm'd file get trashed?  (For this assignment, that would be OK, but a production version, if you were going to release it to the general Unix community, would probably need versions of srm'd files.)  Comment on any important design decisions (like this one) that you make.  Make sure you think carefully; there are easy ways to do this question, and hard ways. 

Hints for #2: define an environment valiable (at login time, in your .login or .profile) called TRASH which tells the scripts where to find the trashcan(s);think about how this variable would need to be changed if somebody else ran them; the scripts should fail gracefully if TRASH is not defined; think about how they would work (or fail) if the trashcan resides on a different partition than the files being srm'd (especially if the file being srm'd is very big).

Operating System, Computer Science

  • Category:- Operating System
  • Reference No.:- M92287343

Have any Question?


Related Questions in Operating System

State the required answer precisely and then provide proper

State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. Briefly describe the following concepts and indicate how they are related in the context ...

Foundation of information technologyresearch types of

Foundation of Information Technology Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Expl ...

Question note apa format 250 words and three reference

Question: Note: APA format 250 words and three reference without plagarism Computerized Operating Systems (OS) are almost everywhere. We encounter them when we use out laptop or desktop computer. We use them when we use ...

Question you are a security administrator responsible for

Question: You are a security administrator responsible for providing secure configuration requirements for new laptop deployments. After reading Module 2 of Certified Secure Computer User v2exercises, apply the configura ...

Assignment -building a multi-threaded web server using c

Assignment - Building a multi-threaded web server using C and p threads, following the model from the lecture. Your program will have one thread acting as a dispatcher thread, listening fornetwork connections with reques ...

Question 1answer the following questions 10 marks a

Question 1 Answer the following questions: 10 marks a. Consider the following page reference string: 3, 1, 4, 1, 2, 3, 5, 3, 2, 1, 2,5, 4, 3, 5, 2, 4,2, 5,3 Using the above page reference string display the contents of t ...

Research types of operating systems that are currently

Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Explain why you think the choice you made ...

Question research hex editors available for mac os and

Question : Research hex editors available for Mac OS and Linux. Based on the documentation, how easy would validating these tools be? Select at least two hex editors for each OS, and discuss what you would do to validate ...

Question topic computerized operating systems os are almost

Question: Topic: Computerized Operating Systems (OS) are almost everywhere. We encounter them when we use out laptop or desktop computer. We use them when we use our phone or tablet. Find articles that describes the diff ...

Taskyour job in this assignment is to create two virtual

Task Your job in this assignment is to create two Virtual machines each running a different but the latest distribution of Linux e.g. Ubuntu Server and CentOS. Each of these VM's is to offer services to a user base. The ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As