September 26, 2022
fatmawati achmad zaenuri/Shutterstock.com Sometimes in Linux scripts, you want to know if a string of text contains a specific, smaller string. There are many ways to do this. We show you some simple, reliable techniques. Why Is This Useful? Searching a string for a smaller substring is a common requirement. One example would be reading…

fatmawati achmad zaenuri/Shutterstock.com

Sometimes in Linux scripts, you want to know if a string of text contains a specific, smaller string. There are many ways to do this. We show you some simple, reliable techniques.

Why Is This Useful?

Searching a string for a smaller substring is a common requirement. One example would be reading text from a file or from human input and searching the string for a specific substring so that your script can decide what to do next. It might be looking for a label or device name in a configuration file or a command string in a line of input from a user.

Linux users are blessed with any number of utilities for manipulating text. Some are built into the Bash shell, others are provided as standalone utilities or applications. There’s a reason Unix-derived operating systems are richly served with string manipulation capabilities.

Some things that appear to be files are not simple files. They’re special files representing things like hardware devices and sources of system information. The abstraction performed by the operating system gives them the appearance and…

Read Full Article Source

Leave a Reply

Your email address will not be published.