Using internal command sh to run linux command, output is scrambled
Moderators: petermad, Stefan2, Hacker
Using internal command sh to run linux command, output is scrambled
I am using the latest version of Total Commander for Android on a Samsung S22 Ultra with the latest Android and OneUI code, as well as the latest version of Toybox. I created a button to run the sh command, setting the parameters field to
"* find . -type f -exec ls -l --full-time {} \;"
When run, I get a list of files shown like this
permissions 1 u0a287 media_rw 34 2025-04-11 20:31:19.193887122-0400 ./file1.txt
I then tried to changed the parameters to be
"* find . -type f -exec ls -l --full-time {} + | awk '{ printf "%7s %s %s\n", $5, %7 %8 }'
I was expecting to get something like
" 34 20:31:19.193887122-0400 ./file1.txt"
but instead I get just
" 34"
Is this just a Toybox bug, or am I doing something wrong ?
By the way, the "*" causes the results to be displayed in a pop up dialog box, when you can close it after viewing.
Thanks for your help.
"* find . -type f -exec ls -l --full-time {} \;"
When run, I get a list of files shown like this
permissions 1 u0a287 media_rw 34 2025-04-11 20:31:19.193887122-0400 ./file1.txt
I then tried to changed the parameters to be
"* find . -type f -exec ls -l --full-time {} + | awk '{ printf "%7s %s %s\n", $5, %7 %8 }'
I was expecting to get something like
" 34 20:31:19.193887122-0400 ./file1.txt"
but instead I get just
" 34"
Is this just a Toybox bug, or am I doing something wrong ?
By the way, the "*" causes the results to be displayed in a pop up dialog box, when you can close it after viewing.
Thanks for your help.
- ghisler(Author)
- Site Admin

- Posts: 53162
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: Using internal command sh to run linux command, output is scrambled
You are missing a comma between %7 and %8, and shouldn't they be $7 and $8?
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Re: Using internal command sh to run linux command, output is scrambled
I made a typing mistake. I am writing these posts on a laptop, yet doing the work on an Android phone. That command I used was actually
"* find . -type f -exec ls -l --full-time {} + | awk '{ printf "%7s %s %s\n", $5, $7, $8 }'
I can even simplify that and try
"* find . -type f -exec ls -l --full-time {} + | awk '{ printf "%s\n", $7 }' OR
"* find . -type f -exec ls -l --full-time {} + | awk '{ printf "%s\n", $8 }'
Those do not yield expected results, the $7 and $8 fields are not shown.
After just playing around I see that something like this
"* find . -type f -exec ls -l --full-time {} + | awk '{ printf "%07s %16s %16s\n", $5, $6, $9 }'
results in
"0000034 2026-04-11 ./f1.txt"
If I do not include the length "flag", like the '16' above, then the value is NOT shown. For some reason the filename is $9 not $8. Using '%07s" leads to the file size of "0000034", but using '%7s' does NOT lead to 5 spaces, and 34 (...or the font is NOT fixed width ??).
To be clearer,
"* find . -type f -exec ls -l --full-time {} + | awk '{ printf "%16s\n", $9 }'
will show the filename,
"* find . -type f -exec ls -l --full-time {} + | awk '{ printf "%s\n", $9 }'
will NOT.
As a software developer, I understand software is rarely perfect, so will figure out a work around to achieve my goals.
"* find . -type f -exec ls -l --full-time {} + | awk '{ printf "%7s %s %s\n", $5, $7, $8 }'
I can even simplify that and try
"* find . -type f -exec ls -l --full-time {} + | awk '{ printf "%s\n", $7 }' OR
"* find . -type f -exec ls -l --full-time {} + | awk '{ printf "%s\n", $8 }'
Those do not yield expected results, the $7 and $8 fields are not shown.
After just playing around I see that something like this
"* find . -type f -exec ls -l --full-time {} + | awk '{ printf "%07s %16s %16s\n", $5, $6, $9 }'
results in
"0000034 2026-04-11 ./f1.txt"
If I do not include the length "flag", like the '16' above, then the value is NOT shown. For some reason the filename is $9 not $8. Using '%07s" leads to the file size of "0000034", but using '%7s' does NOT lead to 5 spaces, and 34 (...or the font is NOT fixed width ??).
To be clearer,
"* find . -type f -exec ls -l --full-time {} + | awk '{ printf "%16s\n", $9 }'
will show the filename,
"* find . -type f -exec ls -l --full-time {} + | awk '{ printf "%s\n", $9 }'
will NOT.
As a software developer, I understand software is rarely perfect, so will figure out a work around to achieve my goals.
Re: Using internal command sh to run linux command, output is scrambled
I did some more playing around, using sh and the cksum command ...
My sh parameters were: "* for file in %S; do cksum $file;done"
This worked with two files selected. I then tried: "* for file in %S; do cksum $file | awk '{ printf "%12s %8s %1s" }';done"
The output WAS NOT spaced properly ... the first 2 fields did NOT appear to take up the specified width. I then tried:
"* for file in %S; do cksum $file | awk '{ printf "%012s %08s %1s" }';done"
and now everything is in perfect columns. This led me to believe the problem is not with my command syntax, but rather what ever is displaying the results in the temporary 'dialog' box. I then tried this: "* for file in %S; do cksum $file | awk '{ printf "%12s %8s %1s" >> "./cks.txt" }';done"
That resulted in a text file "cks.txt" in the current directory with output in perfect columns. In further experimenting I found that using the sh command to output text does so with letters and numbers being displayed in a "fixed width" font. Spaces and symbols like !@#$%^&*( are NOT shown in fixed width font.
My sh parameters were: "* for file in %S; do cksum $file;done"
This worked with two files selected. I then tried: "* for file in %S; do cksum $file | awk '{ printf "%12s %8s %1s" }';done"
The output WAS NOT spaced properly ... the first 2 fields did NOT appear to take up the specified width. I then tried:
"* for file in %S; do cksum $file | awk '{ printf "%012s %08s %1s" }';done"
and now everything is in perfect columns. This led me to believe the problem is not with my command syntax, but rather what ever is displaying the results in the temporary 'dialog' box. I then tried this: "* for file in %S; do cksum $file | awk '{ printf "%12s %8s %1s" >> "./cks.txt" }';done"
That resulted in a text file "cks.txt" in the current directory with output in perfect columns. In further experimenting I found that using the sh command to output text does so with letters and numbers being displayed in a "fixed width" font. Spaces and symbols like !@#$%^&*( are NOT shown in fixed width font.
Re: Using internal command sh to run linux command, output is scrambled
--full-time (already) like -l --time-style=full-isoTcny wrote: 2026-04-12, 14:36 UTC For some reason the filename is $9 not $8.
....
"* find . -type f -exec ls -l --full-time {} + | awk '{ printf "%16s\n", $9 }'
And I would always use instead for such outputs:
-l --time-style=+"%F %T"
Re: Using internal command sh to run linux command, output is scrambled
I found that a string such as "20:31:19.193887122-0400" was be treated as two strings, "20:31:19.193887122" and "-0400".
- ghisler(Author)
- Site Admin

- Posts: 53162
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: Using internal command sh to run linux command, output is scrambled
That's odd, the default field separator should be a space. Maybe you can set it explicitly via -F switch, e.g.
awk -F' ' '{ printf "%16s\n", $8 }'
awk -F' ' '{ printf "%16s\n", $8 }'
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Re: Using internal command sh to run linux command, output is scrambled
I have my project working. Thanks for the help for those responding.
Just curious, does anyone know if there is a character limit to the size of the "parameters" for the internal sh command ?
Just curious, does anyone know if there is a character limit to the size of the "parameters" for the internal sh command ?
Re: Using internal command sh to run linux command, output is scrambled
xargs --show-limits
getconf ARG_MAX
getconf ARG_MAX

