Hi,
1)I have XX directory and have lot of files ,I want to find largest file in that
directory
2)how calculate the size of file in MB.
Thanks,
Mohan
Hi,
1)I have XX directory and have lot of files ,I want to find largest file in that
directory
2)how calculate the size of file in MB.
Thanks,
Mohan
This will bring the largest file in the directory. But if the directory has the maximum size then it would list the directory rather than the files.
du -ms * | sort | tail -1
I was getting the below error ,OS is HP unix
$ du -ms * | sort | tail -1
du: illegal option -- m
usage: du [-a|-s] [-kbrx] [-t type] [name ...]
Thanks ,
Mohan
My OS is an Linux version one, let me check out for the HP-UX.
Try using the following command,
du -a | sort -n | tail -2 | head -1 | cut -f2
Thanks,
Seetharaman
Hi,
Its working for less file size ,can u explain the syntax.
Thanks,
Mohan
Can you just tell me if there is any problem if the file size is larger???
Thanks,
Seetharaman
Hi,
I want to find out the biggest file size in direcorty.
Thanks,
Mohan
In the Directry Give....
ls -ls|sort -nr|head -1
that gives the largest file statistics...
It is working for find the bigger file size in current directory both in HP-UX and in Linux (open Suse). But if there is a bigger sized directory around it will point that.
Hi,
Please find the answer
#!/bin/ksh
calc_size=0
for i in `ls -l|grep "^-"|awk '{print $5"|"$9}'`
do
fname_size=`echo "$i"|awk -F"|" '{print $1}'`
if [ $fname_size -ge $calc_size ];then
calc_size=$fname_size
fname=`echo "$i"|awk -F"|" '{print $2}'`
fi
done
echo "File \"$fname\" is the largest with size $calc_size"
since you said you are working on linux, i don't think so you have korn shell. You execute by changing first line like
#!/bin/sh
Thanks,
Shahnaz.
with GNU find
find /path -type f -printf "%s:%f\n"|sort -n|tail -1
With recent versions of zsh:
ls -fl *(.DOL[1])
Beware: the actual bytes and allocated bytes of file may differ.
so write down a little bit code
#!/bin/zsh
ls -fl *(.DOL[1])
How about this
du -a | sort -g
may be this is better in look:
du -a | sort -g |tail -2 | cut -f2