Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

checking file size after ftp

Posted on 2001-08-15
6
Medium Priority
?
259 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 260 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

879 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