I have a list of files
- shopping-list.txt
- our-shopping-list.txt
- test.txt
- my-test.txt
I want to run myscript shopping
and get the two files that have the word shopping
. I want to run myscript our list
and get just the one file.
at the moment I have this
if [[ $fs =~ .*${*}*.* ]]; then
echo $fs
fi
It works a bit, but it would not give me our-shopping-list
if each variable has a gap ie. myscript our list
it would work if I typed myscript our - list
I have a big list of files and want to find the one I need by guessing the name
my attempt to apply @pacholik's code
snippetdir="~/my_snippets/"
for filename in $snippetdir*; do
file=`basename "$filename"`
fs=${file%.*}
for i in ${*}; do
for j in *${i}*; do
if [[ $fs =~ .*$j*.* ]]; then
echo $fs
fi
done
done
done