I need some help with using grep in a script. In the script I have
arc_src_UUID1=`ls -l /dev/disk/by-label | grep "$arc_src_label"`, where arc_src_label contains e.g. "Abcde"
Grep finds all occurences of "Abcde", including "Abcde", "Abcdef", "Abcdefg", etc., whereas I only want "Abcde". Adding a space to the contents of arc_src_label has no effect (it looks as though grep ignores this space).
In a terminal the following works
ls -l /dev/disk/by-label | grep "Abcde ", i.e. embedding the pattern-string (plus a space) in "" solves the problem - only "Abcde" is found. Since this clearly works, I assume that it's a script-syntax problem.
Can anyone help me out with the correct syntax? Thanks.