Re: substituing $1 one time but not the other



Ed Morton wrote:

<snip>

missed those pesky "<>"s. fixed below.

I don't really know what you mean by that question, but everything before it seems to imply that what you to is instead of this:

grep '^Message-ID: <my id>$' myfolder/* | awk -F ':' '{print $1;}'

be able to do this:

myid="$1"
myfolder="$2"
grep "^Message-ID: ${myid}$" "${myfolder}"/* | awk -F ':' '{print $1;}'
grep "^Message-ID: <${myid}>$" "${myfolder}"/* | awk -F ':' '{print $1}'

By the way you don't need grep AND awk since awk can cheerfully do pattern matching on it's own:

myid="$1"
myfolder="$2"
awk -F: -v myid="$myid" '$0 ~ "^Message-ID: " myid "$"{print $1}' "${myfolder}"/*
awk -F: -v myid="$myid" '$0 ~ "^Message-ID: <" myid ">$"{print $1}' "${myfolder}"/*

Regards,

Ed.
.