I have a file mixed with lower-case letters and upper-case letters, can I use awk
to convert all the letters in that file into upper-case?
You can use `tr` command in the following way also to convert any string from lowercase to uppercase.
The ^ operator converts to uppercase, while , converts to lowercase. If you double-up the operators, ie, ^^ or ,, , it applies to the whole string; otherwise, it applies only to the first letter (that isn't absolutely correct - see "Advanced Usage" below - but for most uses, it's an adequate description).
'^' symbol is used to convert the first character of any string to uppercase and '^^' symbol is used to convert the whole string to the uppercase. ',' symbol is used to convert the first character of the string to lowercase and ',,' symbol is used to convert the whole string to the lowercase.
Try this:
awk '{ print toupper($0) }' <<< "your string"
Using a file:
awk '{ print toupper($0) }' yourfile.txt
You can use awk
, but tr
is the better tool:
tr a-z A-Z < input
or
tr [:lower:] [:upper:] < input
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With