write a scwipt that
a) takes exactly one argument, a directory name.
b) if the number of argument is more or less than one,print
a usage message
c) if the argument is not adirectory, print another message
d) for the given directory, print the five biggest files
and the five files that were most recently modified.
e) save the output to a file called q2output.

Answer Posted / sudhir

for var in `ls -1S` === -S sort the file primary key as
size of the file and -1 column o/p
do
if [[ $i -eq 5 ]]
then
break;
fi
print $var
let i=i+1;
done

Same code can be used for time and ls command option will be
ls -1t

Is This Answer Correct ?    3 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between grep and egrep?

615


What is bourne shell scripting?

534


How to replace following lines, catch (DAOException e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw new BOException(5122); } catch (BOException e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw e; } catch (Exception e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw new BOException(5122); } Needs to be changed in to, catch (DAOException e) { AppException.handleException (null, null, e, null, null, null, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 5122); } catch (BOException e) { AppException.handleException (null, null, null, e, null, null, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 0); } catch (Exception e) { AppException.handleException (null, null, null, null, null, e, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 5122); }

1859


How to print all the arguments provided to the script?

557


Hello all, This is my assignment on shell scripting, can anyone help me regarding this ? Create a shell script which connects to the database In second shell script include the first script for the DB connection Create a table (PRADEEP_DATA) with 2 columns (name, value) In Third shell script include the first script for the DB connection And insert/delete the values from the Table, by accepting input from the user This functionality should be a menu driven Program: 1) Insert to the database a. Name b. value 2)Delete from the database a.Name b.value Exception handling needs to be taken care.

1857






How to print all array elements and their respective indexes?

512


What does $1 mean in bash?

618


How to get the last line from a file using just the terminal?

674


What does sh mean?

622


Why is the use of shell script?

545


How will you emulate wc –l using awk?

913


How do I set bash as default shell mac?

559


What is a command line shell?

567


What is the difference between break and continue commands?

579


What are the different variables present in linux shell?

614