l0ckm4 l0ckm4 - 9 months ago 28
Linux Question

Linux Bash Script - match lower case path in argument with actual filesystem path

I have a linux script that gets an argument passed to it that originates from MSDOS (actually DOSEMU running MS DOS 6.22). The argument that gets passed is case insensitive (as DOS didn't do cases) but of course Linux does.

I am trying to get from the following passed argument




I do not know the actual case sensitive path so I need to somehow determine it from the argument that is passed to the script. I have absolutely no idea where to start with this so any help is greatly appreciated.

edited for extra information and clarity


Thanks to the answer by @anubhava I used the following:-


if [ ! -z "$2" ]; then

find / -readable -ipath $1 2>&1 | grep -v "Permission denied" | while IFS= read -r FILE; do
lpr -o Collate=True -#$copies -sP $FILE

Works great :-)


You can use -ipath option of find for ignore case path matching:

# assuming $arg contains path argument supplied
find . -ipath "*$arg*"