Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Shell script help

Name: Anonymous 2010-11-03 22:18

How can I change my code to be able to compare the size of two files.

if [ -f $1 ] && [ -f $2 ] && [ ! $1 -ef $2 ]; then
    size1=$(du $1)
    size2=$(du $2)
    if [ $1 -gt $2 ]; then
     echo "$1 is bigger"
    else
      echo "$1 is smaller"
    fi
fi

Name: Anonymous 2010-11-03 23:50

>>7
>>5
intENTERPRISE_C(char *f1, char *f2){
    FILE *f1ptr;
    FILE *f2ptr;
   
    if(!(f1ptr=fopen(f1,'b')) || !(f2ptr=fopen(f2,'b'))){
        fprintf(stderr,"Failed to open files\n");
        return -1;
    }
    fseek(f1ptr,0,SEEK_END);
    fseek(f2ptr,0,SEEK_END);
    if(ftell(f1ptr) > ftell(f2ptr))
        printf("File 1 is bigger");
    else
        printf("File 2 is bigger");
    return 0;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List