grep1-1 Exercise 2: Three Ways to Find 3.1.4 ============================================= cat > releases.txt <<'EOF' 3.1.4 3x1x4 3.1.4-beta v3.1.4 31.14 EOF echo "plain: grep '3.1.4'" grep '3.1.4' releases.txt echo echo "fixed string: grep -F '3.1.4'" grep -F '3.1.4' releases.txt echo echo "fixed string, whole line: grep -Fx '3.1.4'" grep -Fx '3.1.4' releases.txt Output: plain: grep '3.1.4' 3.1.4 3x1x4 3.1.4-beta v3.1.4 fixed string: grep -F '3.1.4' 3.1.4 3.1.4-beta v3.1.4 fixed string, whole line: grep -Fx '3.1.4' 3.1.4 WHY THIS WORKS AS AN ANSWER --------------------------- Plain: each dot means 'any one character', so 3x1x4 matches too (x stands for the dots), and 3.1.4-beta and v3.1.4 match because the pattern may appear anywhere in the line. 31.14 does not match: it has no 3, any, 1, any, 4 in a row. -F turns the dots into plain dots, which removes 3x1x4 but keeps the longer lines that contain 3.1.4. -Fx demands that the whole line be exactly 3.1.4, which leaves one line. Which of the three is right depends on what you meant by 'version 3.1.4'; the point is to choose, not to take whatever the default gives you.