Introduction
The tr command changes or deletes characters in text. It helps fix or clean text quickly.
tr [options] SET1 [SET2]
echo "hello" | tr 'a-z' 'A-Z'
echo "123abc" | tr -d '0-9'
echo "hello world" | tr ' ' '_'
#!/bin/bash # Convert lowercase to uppercase input="hello world" output=$(echo "$input" | tr 'a-z' 'A-Z') echo "$output"
tr command do in bash scripting?trtr command is used to translate or delete characters from input text streams.tr = transform/delete characters [OK]tr?'a-z' as source and 'A-Z' as target.tr 'a-z' 'A-Z'. Other options either reverse case or use wrong ranges.echo "Hello World 123" | tr -d '0-9'
-d option in tr-d option deletes characters matching the set given, here digits '0-9'.echo "abc123" | tr 'a-z' 'A-Z' -d '0-9'
tr option usagetr does not support combining translation and deletion in one command; they are separate operations.trPass the test and this pattern moves unknown