Ive been having trouble getting my bash script to accept wildcards when there are multiple arguments, and am just trying to use this with an ls as described below:
Say I have these 4 files in the directory
Code:
abc123.txt
abc456.txt
xyz789.txt
123xyz.txt
I essentially have a script like this called test_script
Code:
arg1=$1
arg2=$2
ls $arg1 > chk1.txt
ls $arg2 > chk2.txt
I can get the results I want to obtain by running the script as:
Code:
test_script "*abc*" "*xyz*"
However I need others to use this scripts and normally we dont need to quote things in order to get the wildcards to work
I have tried using $@ (although I really dont know what this does), but can only seem to get that to work properly if there is only one argument given.
Any advice?
Thanks