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
How do I run a .sh file?
Explain how you Automate your application using Shell scripting.
What is the first line in every perl script called?
What is shell geeksforgeeks?
What is inside a seashell?
How to get script name inside a script?
shell script for reverse the string
How to print all the arguments provided to the script?
How can the contents of a file inside jar be read without extracting in a shell script?
I have to write Shells (Linux + Unix)for publishing packages and reports. Is it possible ? What are the differents executable programs ineed to call ?
What does echo $0 do?
Write a command sequence to find all the files modified in less than 2 days and print the record count of each.
What is the syntax of "nested if statement" in shell scripting?
What are the zombie processes?
Give some situations where typing error can destroy a program?