I'm trying to pass text with a space (in this case a date,e.g. Jan 20) as a parameter to grep in a shell script.
tst.sh filename.txt Jan 20 # where $1 is filename.txt, $2 is Jan 20
#!/bin/bash
cat $1 | grep $2
grep err's out with grep: 20: No such file or directory
Can anyone suggest a method to make this work, please?
I've tried quotes, brackets, etc. I've looked at bash special parameters but still can't wrap what's left of my brain around what's probably trivial.
I could do a sed / awk search and replace on the date to turn it from Jan 20 to 0120 which I know how to deal with but I'd like to learn how to work with a "block of chars
with embedded spaces" as a parm for the next time that it comes up.
TIA!
maurie
tst.sh filename.txt Jan 20 # where $1 is filename.txt, $2 is Jan 20
#!/bin/bash
cat $1 | grep $2
grep err's out with grep: 20: No such file or directory
Can anyone suggest a method to make this work, please?
I've tried quotes, brackets, etc. I've looked at bash special parameters but still can't wrap what's left of my brain around what's probably trivial.
I could do a sed / awk search and replace on the date to turn it from Jan 20 to 0120 which I know how to deal with but I'd like to learn how to work with a "block of chars
with embedded spaces" as a parm for the next time that it comes up.
TIA!
maurie