I'm trying to make some custom scripts and I have a few questions about basic operations that don't work as I expected.
(#!/bin/sh)
1) How can I check if a string a contains a substring b?
For example, a=abcde and b=abc.
The typical [[ $a == *"abc"* ]] doesn't work.
I've resorted to [ -z "${a##*$b*}" ], is that the only way?
2) How to convert a string from uppercase to lowercase or the opposite?
For example, a=ABCDE123. How to assign it to string b like "abcde123"?
3) Is there a command for case insensitive comparison of strings?
E.g. "ABC" to "abc".
4) Is there a way to get blkid to return device assignment (/dev/sda1, /dev/sda2, etc) based on exact match of partition label or UUID?
5) Can I log devices' mounting points?
E.g., device sda1 mounted to tmp/mnt/x
(#!/bin/sh)
1) How can I check if a string a contains a substring b?
For example, a=abcde and b=abc.
The typical [[ $a == *"abc"* ]] doesn't work.
I've resorted to [ -z "${a##*$b*}" ], is that the only way?
2) How to convert a string from uppercase to lowercase or the opposite?
For example, a=ABCDE123. How to assign it to string b like "abcde123"?
3) Is there a command for case insensitive comparison of strings?
E.g. "ABC" to "abc".
4) Is there a way to get blkid to return device assignment (/dev/sda1, /dev/sda2, etc) based on exact match of partition label or UUID?
5) Can I log devices' mounting points?
E.g., device sda1 mounted to tmp/mnt/x