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
Why is the use of shell script?
What is meant by dos operating system?
Is shell scripting a language?
How will you emulate wc –l using awk?
How do you debug a script?
How can you find out how long the system has been running?
What is the difference between break and continue commands?
I want to create a directory such that anyone in the group can create a file and access any person's file in it but none should be able to delete a file other than the one created by himself.
shell script for reverse the string
Print the 10th line without using tail and head command.
How to pass an argument to a script?
What does the sh command do?
What is the use of "$#" in shell scripting?
How will you copy a file from one machine to other?
write a shell script to check the failed jobs?