Solved

checking file size after ftp

Posted on 2001-08-15
6
228 Views
Last Modified: 2010-04-21
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
0
Comment
Question by:john_t
  • 4
  • 2
6 Comments
 
LVL 6

Expert Comment

by:bira
ID: 6389702

  wc -l file     ( to get the size in lines )
  wc -c file     ( to get the size in bytes )
0
 
LVL 6

Expert Comment

by:bira
ID: 6389717

 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
 

Author Comment

by:john_t
ID: 6389819
what if I want only size of the file and store it in a variable?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 6

Expert Comment

by:bira
ID: 6389835
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
 
LVL 6

Accepted Solution

by:
bira earned 65 total points
ID: 6389857
Another simple way to do that :

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

Author Comment

by:john_t
ID: 6390291
thank you bira
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now