[vox-tech] BASH: ignore space in for loop
Ken Herron
kherron+lugod at fmailbox.com
Wed Oct 20 13:28:08 PDT 2004
Dylan Beaudette wrote:
> The "Name of place" values often have spaces in them, which seems to be
> confusing a for loop in bash:
>
> running:
> for this_quadname in `cat file_a`; do echo grep -i "$this_quadname" file_b ;
> done
while read pattern
do
grep -i "$pattern" file_b
done < file_a
or
cat file_a | while read pattern
do
grep -i "$pattern" file_b
done
> PS I am merely trying to implement a simple many-to-one join on 2 text files
> based on a common key, which is the first column in each file... however the
> spaces in the keys are messing up the conventional 'join' program...
You should be able to specify the field separator using join's -t
option...?
More information about the vox-tech
mailing list