Skip to main content

βš™οΈ 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"