Converting a string to lower case

Fish Shell:
Converting a string to lower case

How to:

Using the string command, converting text to lower case is straightforward. Just do:

echo "MAKE ME LOWERCASE" | string lower

Sample output:

make me lowercase

For a variable:

set my_string "SHOUTY CASE TEXT"
string lower -q -- $my_string

Output:

shouty case text

Deep Dive:

Before Fish Shell, Unix users often used tr '[:upper:]' '[:lower:]' or awk '{print tolower($0)}'. While these work, they’re not as clean or straightforward as Fish’s built-in string lower function.

Fish introduced string in v2.3.0 (May 2016), elevating string manipulation to be a core part of the shell, rather than requiring external commands. This added simplicity and speed to common tasks like case conversion.

Why not just use tr or awk? string lower is built into Fish, meaning it’s faster (no spawning new processes) and works in a consistent and predictable manner across different systems. It’s also part of a broader string command suite that handles other string operations, which can make script writing tidier and more efficient.

See Also: