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.
Answers were Sorted based on User's Feedback
Answer / 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 |
How will I insert a line "abcdef" at every 100th line of a file?
What is the syntax of "nested if statement" in shell scripting?
How will you pass and access arguments to a script in linux?
write a shell script to find the largest number from 3 given numbers.
How do I debug a shell script?
Write a command sequence to find the count of each word?
shell script for reverse the string
How can the contents of a file inside jar be read without extracting in a shell script?
Explain about login shell?
What is the use of a shebang line?
How will you connect to a database server from linux?
What are the two files of crontab command?