βοΈ Subprocesses
Subprocesses let you run commands within your script and use their results. This guide explains how to run subprocesses and work with their output.
Running a Subprocessβ
Wrap any command in $()
to run it and use its output right away.
Examplesβ
# Convert text to uppercase
ui_print "$(string upper "hello")" # Prints "HELLO"
# Combine with text
ui_print "$(string upper "hello") everyone" # Prints "HELLO everyone"
Storing the Outputβ
Assign the result to a variable for later use:
result=$(string upper "welcome")
ui_print "$result everyone" # Prints "WELCOME everyone"
Real-World Useβ
Get a fileβs size dynamically:
size=$(getsize "/sdcard/file.txt")
ui_print "File size is $size bytes"