Solved

checking file size after ftp

Posted on 2001-08-15
6
232 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Shell script errors 10 133
KSH What's the best way to pass multiple variables (some may be blank) to a function? 5 51
Where to get php 5.6 for AIX 7.1? 5 100
awk sed 8 42
When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

772 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