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

How to Install nvidia-smi on Ubuntu or Debian Linux

In this article, we will see how to install nvidia-smi on Ubuntu or Debian Linux.…

9 hours ago

How to Install clang tool on Ubuntu or Debian Linux

In this article, we will see how to install clang tool on Ubuntu or Debian…

1 day ago

How to resolve Ubuntu 20.04 Container Signature Errors on Raspberry Pi ARM Devices

When working with Docker containers on Raspberry Pi devices, you might encounter frustrating signature verification…

2 days ago

How to fix DNS Resolution Issues with OpenVPN on Ubuntu 18.04

You’ve recently upgraded to Ubuntu 18.04 and found that your OpenVPN connection no longer resolves…

2 days ago

How to Fix Ubuntu 18.04 System Monitor Launch Issues

Have you ever tried to open System Monitor on your Ubuntu 18.04 system only to…

3 days ago

What is System Hardening? Essential Checklists from OS to Applications

System hardening means locking down a system and reducing its attack surface: removing unnecessary software…

3 days ago