checking file size after ftp

I am using ftp to get a file from another server. How can I cross-check the size of a file in korn shell script
john_tAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
biraConnect With a Mentor Commented:
Another simple way to do that :

  a=`wc -c file |awk '{print $1}'`
  echo $a
0
 
biraCommented:

  wc -l file     ( to get the size in lines )
  wc -c file     ( to get the size in bytes )
0
 
biraCommented:

 If you want to find out only the number of lines of a file:

wc -l file |while read x z
do
echo $x
done
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
john_tAuthor Commented:
what if I want only size of the file and store it in a variable?
0
 
biraCommented:
Here is an script example

rsh remoteserver wc -c file|while read x z
                          do
                          init=$x
                          echo $init
                          done

     ftp -n remoteserver   << final
        user username password
        cd /path
        get file
        bye
final
wc -c file|while read x z
           do
           end=$x
           echo $end
           done
    if [ $init -ne  $end ] ;  then
        echo "Size of the original file is different from the file got by ftp."
       else
      echo "Ok..."
    fi
#
0
 
john_tAuthor Commented:
thank you bira
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.