How to convert filenames or text to lowercase on the Linux command line

There is no simple ‘tolower’ command on the bash, but you can convert uppercase characters to lowercase with a little shell script. The script uses the tr command internally for converting the chars.

Create a shell script with the name ‘tolower’ that converts all text that is given as a command-line argument to lower case:

nano /usr/local/bin/tolower

and enter the following content:

#!/bin/sh
echo $1 | tr '[:upper:]' '[:lower:]'

Then make the script executable:

Sponsored
chmod +x /usr/local/bin/tolower

An test it by executing this command on the shell:

tolower "Thats a Test"

will convert the string to lowercase and show the result on the shell:

thats a test
Sponsored

The post How to convert filenames or text to lowercase on the Linux command line appeared first on FAQforge.

Ubuntu Server Admin

Recent Posts

Canonical announces 12 year Kubernetes LTS

Canonical’s Kubernetes LTS (Long Term Support) will support FedRAMP compliance and receive at least 12…

23 hours ago

Ubuntu Weekly Newsletter Issue 878

Welcome to the Ubuntu Weekly Newsletter, Issue 878 for the week of February 2 –…

2 days ago

How your feedback shapes the way we support open source software

At Canonical, we firmly believe that delivering an outstanding, customer-centric support experience is impossible without…

2 days ago

How To Install osTicket v1.14 On Ubuntu 20.04

I want to share how to install osTicket v1.14 for Ubuntu 20.04 server. osTicket written…

3 days ago

How To Install WordPress On Ubuntu 20.04

Now I want to share how to install WordPress on ubuntu 20.04 server. WordPress is…

3 days ago

How To Install DNS Server (Bind9) On Ubuntu 20.04

Now I want to share the DNS server installation process on your Ubuntu 20.04 server.…

3 days ago