You are not logged in.
Pages: 1
Yes of course, I could just do an ls -hl, but I just want to see the filesizes only (and the names next to it to distinguish). I wonder if anyone else finds it useful
(You can name it whatever you want, but my binary name is "fsize")
#include <stdio.h>
int main(int argc, char *argv[])
{
FILE *f;
int g, m, k, b;
int i, total;
for(i = 1; i < argc; i++)
{
f = fopen(argv[i], "rb");
if(f == 0)
{
printf("the file %s does not existn", argv[i]);
continue;
}
fseek(f, 0, SEEK_END);
total = ftell(f);
fclose(f);
g = total / 1073741824;
total = total % 1073741824;
m = total / 1048576;
total = total % 1048576;
k = total / 1024;
total = total % 1024;
b = total;
printf( "%uGt%uMt%uKt%ut- %sn", g, m, k, b, argv[i]);
}
return 0;
}
Output looks like:
[danielm@localhost fsize]$ fsize *
0G 0M 0K 0 - README
0G 0M 5K 194 - fsize
0G 0M 0K 543 - fsize.c
0G 0M 0K 0 - fsize.sh
Offline
Also exist the "du" command.
du -mahc *
4,0K CVS/Root
4,0K CVS/Repository
4,0K CVS/Entries
12K CVS
12K total
irc.bsd.cl #linux
irc.freenode.org #archlinux-es
Offline
$ stat /path/to/file | grep Size | awk -F " " '{print $2;}'
~Peter~
Offline
$ stat /path/to/file | grep Size | awk -F " " '{print $2;}'
Awww so you're telling me I could have just created an alias to that? Either way it was only 5 mins of coding .
Offline
Pages: 1