Skip to main content
added 8 characters in body
Source Link
Gilles Quénot
  • 36.5k
  • 7
  • 74
  • 96

You need to change the quotes:

for i in {1..5}
do
    echo "${2}.svg" | grep "rect'rect x=\042$i\042"x = '$'\042'$i$'\042' && do_something_if_${i}_is_found
done

\042 is the ASCII representation of double quotes.

Check man ascii

Or simply:

grep "rect x=\"$i\""

You need to change the quotes:

for i in {1..5}
do
    echo "${2}.svg" | grep "rect x=\042$i\042" && do_something_if_${i}_is_found
done

\042 is the ASCII representation of double quotes.

Check man ascii

You need to change the quotes:

for i in {1..5}
do
    echo "${2}.svg" | grep 'rect x = '$'\042'$i$'\042' && do_something_if_${i}_is_found
done

\042 is the ASCII representation of double quotes.

Check man ascii

Or simply:

grep "rect x=\"$i\""
Source Link
Gilles Quénot
  • 36.5k
  • 7
  • 74
  • 96

You need to change the quotes:

for i in {1..5}
do
    echo "${2}.svg" | grep "rect x=\042$i\042" && do_something_if_${i}_is_found
done

\042 is the ASCII representation of double quotes.

Check man ascii