Results 1 to 7 of 7

Thread: Need help working with pv's -s SIZE argument

  1. #1
    Join Date
    Jun 2008
    Location
    Cleveland, TN USA
    Posts
    412

    Default Need help working with pv's -s SIZE argument

    I am having trouble with the -s SIZE argument for pv, I get the size of the file and directory that I am working with this code:
    ---
    size=`du -b | grep -v '/' | awk '{print $1}'`
    ---

    As you can see the size gets put in a variable called size, but the problem comes when I need to tell pv if this is it bites, kilobytes, megabytes, gigabytes, etc. The ways I have tried are:

    ---
    pv -pterb -s ($size)k
    pv -pterb -s "$size"k
    pv -pterb -s `$size`k
    pv -pterb -s $size\k
    ---

    All my tries have ended in a failure.
    --
    "We must plan for freedom, and not only for security, if for no other reason than only freedom can make security more secure." Karl Popper

  2. #2
    Join Date
    Jun 2008
    Location
    Schenectady, NY
    Posts
    138

    Default Re: Need help working with pv's -s SIZE argument

    Can you move the 'k' to where your setting $size?

    Code:
    size="`du -b | grep -v '/' | awk '{print $1}'`k"
    When I dump that in a test script and echo $size I get the following:

    135308350986k

  3. #3
    Join Date
    Jun 2008
    Location
    Cleveland, TN USA
    Posts
    412

    Default Re: Need help working with pv's -s SIZE argument

    I don't think pv likes something that
    Code:
    size="`du -b | grep -v '/' | awk '{print $1}'`k"
    is doing because when I use it with pv I get this

    pv: option requires an argument -- 's'
    Try `pv --help' for more information.

    pv does have the $size variable for -s
    "We must plan for freedom, and not only for security, if for no other reason than only freedom can make security more secure." Karl Popper

  4. #4
    Join Date
    Sep 2008
    Location
    Bangalore, India
    Posts
    70

    Default Re: Need help working with pv's -s SIZE argument

    You code should be:
    Code:
    size=`du -b | grep -v '/' | awk '{print $1}'` (Same as yours)
    pv -pterb -s "${size}"k
    That should do the trick. Let us know if that worked.

    - Thejaswi Raya

  5. #5
    Join Date
    Jun 2008
    Location
    Cleveland, TN USA
    Posts
    412

    Default Re: Need help working with pv's -s SIZE argument

    Maybe modify what you have because now I get then

    pv: -s: integer argument expected


    maybe it should be something like:

    Code:
    pv -pterb -s "${size}k"
    "We must plan for freedom, and not only for security, if for no other reason than only freedom can make security more secure." Karl Popper

  6. #6
    Join Date
    Sep 2008
    Location
    Bangalore, India
    Posts
    70

    Default Re: Need help working with pv's -s SIZE argument

    Quite possible. Does "${size}k" work now?

  7. #7
    Join Date
    Jun 2008
    Location
    Cleveland, TN USA
    Posts
    412

    Default Re: Need help working with pv's -s SIZE argument

    No it has the same error as before.
    "We must plan for freedom, and not only for security, if for no other reason than only freedom can make security more secure." Karl Popper

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •