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

Write the syntax for "if" conditionals in linux?

669


How does path variable work?

618


What is echo in shell?

746


What are the advantages of using shell scripts?

660


Write down the syntax for all the loops in shell scripting.

745






Set up a Sev 2 alert when the Primary WA service fails. A windows batch script needs to be created that will monitor the WA service on the Primary and when the service stops/fails a Sev 2 TT is generated for a particular team ?

1801


Is cmd a shell?

679


What is $1 in shell scripting?

679


What is batch file programming?

788


Print the 10th line without using tail and head command.

1787


Explore about environment variables?

678


What are the two files of crontab command?

723


What is the use of "$?" Sign in shell script?

696


write a shell script to check the failed jobs?

4036


How can I set the default rwx permission to all users on every file which is created in the current shell?

1043