Bash intercepting wildcard in script

Posted by MrRoth on Stack Overflow See other posts from Stack Overflow or by MrRoth
Published on 2012-08-29T09:05:06Z Indexed on 2012/08/29 9:38 UTC
Read the original article Hit count: 157

Filed under:
|

I am using Bash script to read line by line from a text file, which has special characters in it (regular expression). When I use echo "${SOME_VAR}" it does not display the text as is.

I am familiar with Prevent * to be expanded in the bash script.

How can I display and use the text as is?

UPDATE The text (TSV) file holds tuples similar to (the last entry is a psql query)

bathroom    bathroom    select name from photos where name ~* '\mbathroom((s)?|(''s)?)\M';

I am reading the CSV as follows:

tail -n+2 text.file | while IFS=$'\t' read x y z
do
    echo "${z}"
done

which gives the output

select name from photos where name ~* 'mbathroom((s)?|(''s)?)M');

note that the '\' is missing

© Stack Overflow or respective owner

Related posts about linux

Related posts about bash