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
In my bash shell I want my prompt to be of format '$"present working directory":"hostname"> and load a file containing a list of user-defined functions as soon as I log in, how will you automate this?
What are the types of script?
What is scripting used for?
Is shell a scripting language?
How do I start a shell script?
What is the difference between break and continue commands?
What makes c shell a more preferable option than the bourne shell?
What are zombie processes?
Explain about "s" permission bit in a file?
Why are there shells on the beach?
What can scripts do?
how will you find the total disk space used by a specific user?
What is difference between shell and bash scripting?
How will you copy a file from one machine to other?
What is the conditional statement in shell scripting?