• sprintf: max number of characters printed?

    From Konstantinos Anagnostopoulos@21:1/5 to All on Tue Nov 2 10:00:41 2021
    Hi I am trying to write a string to be used as a command in a script.

    When the filenames are too long the string get truncated. See e.g.:

    files="aaaD_01.ava0 aaaD_02.ava0 aaaD06N0012n0004s+01.0000k001.0000B001.0000K000.9368i-02.2617e+00.0000m+01.0000g02.ava0 1234567890123456789012345678901234567890123456789001234567890012345678900123456789001234567890"

    do for [f in files]{ print sprintf("head %s|awk '/srkappa/{printf \"(\%7.4f,\%7.4f)\",$4,$5}'",f)}

    Produces the output:

    head aaaD_01.ava0|awk '/srkappa/{printf "(%7.4f,%7.4f)",$4,$5}'
    head aaaD_02.ava0|awk '/srkappa/{printf "(%7.4f,%7.4f)",$4,$5}'
    head aaaD06N0012n0004s+01.0000k001.0000B001.0000K000.9368i-02.2617e+00.0000m+01.0000g02.ava0|awk '/srkappa/{printf "(%7.4f,%7.4f)",$
    head 1234567890123456789012345678901234567890123456789001234567890012345678900123456789001234567890|awk '/srkappa/{printf "(%7.4f,%7


    i.e. the last two commands are incomplete. Is there a way to control this output? Thank you.

    I am suing gnuplot 5.2 patchlevel 8 last modified 2019-12-01 on ubuntu 20.04.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Konstantinos Anagnostopoulos@21:1/5 to Konstantinos Anagnostopoulos on Tue Nov 2 10:40:50 2021
    OK, replacing %s -> %120s (or %-120s) does not chop the command and prints it correctly, but it is still a mystery why %s prints the output as mentioned before since it does not chop the string corresponding to %s but the last characters of the
    resulting string.

    files="aaaD_01.ava0 aaaD_02.ava0 aaaD06N0012n0004s+01.0000k001.0000B001.0000K000.9368i-02.2617e+00.0000m+01.0000g02.ava0 1234567890123456789012345678901234567890123456789001234567890012345678900123456789001234567890END"

    do for [f in files]{ print sprintf("head %120s|awk '/srkappa/{printf \"(\%7.4f,\%7.4f)\",$4,$5}'",f)}
    head aaaD_01.ava0|awk '/srkappa/{printf "(%7.4f,%7.4f)",$4,$5}'
    head aaaD_02.ava0|awk '/srkappa/{printf "(%7.4f,%7.4f)",$4,$5}'
    head aaaD06N0012n0004s+01.0000k001.0000B001.0000K000.9368i-02.2617e+00.0000m+01.0000g02.ava0|awk '/srkappa/{printf "(%7.4f,%7.4f)",$4,$5}'
    head 1234567890123456789012345678901234567890123456789001234567890012345678900123456789001234567890END|awk '/srkappa/{printf "(%7.4f,%7.4f)",$4,$5}'




    On Tuesday, November 2, 2021 at 7:00:44 PM UTC+2, Konstantinos Anagnostopoulos wrote:
    Hi I am trying to write a string to be used as a command in a script.

    When the filenames are too long the string get truncated. See e.g.:

    files="aaaD_01.ava0 aaaD_02.ava0 aaaD06N0012n0004s+01.0000k001.0000B001.0000K000.9368i-02.2617e+00.0000m+01.0000g02.ava0 1234567890123456789012345678901234567890123456789001234567890012345678900123456789001234567890"

    do for [f in files]{ print sprintf("head %s|awk '/srkappa/{printf \"(\%7.4f,\%7.4f)\",$4,$5}'",f)}

    Produces the output:

    head aaaD_01.ava0|awk '/srkappa/{printf "(%7.4f,%7.4f)",$4,$5}'
    head aaaD_02.ava0|awk '/srkappa/{printf "(%7.4f,%7.4f)",$4,$5}'
    head aaaD06N0012n0004s+01.0000k001.0000B001.0000K000.9368i-02.2617e+00.0000m+01.0000g02.ava0|awk '/srkappa/{printf "(%7.4f,%7.4f)",$
    head 1234567890123456789012345678901234567890123456789001234567890012345678900123456789001234567890|awk '/srkappa/{printf "(%7.4f,%7


    i.e. the last two commands are incomplete. Is there a way to control this output? Thank you.

    I am suing gnuplot 5.2 patchlevel 8 last modified 2019-12-01 on ubuntu 20.04.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)