Skip to main content
Rollback to Revision 1
Source Link
user232326
user232326

For the portable way to test if an string contains a substring, use:

file="JetConst_reco_allconst_4j2t.png";       testseq="gen"

[ "${file##*$testseq*}" != "$file" ] &&|| echo True Substring is present

Or "${file##*"$testseq"*}" to avoid interpreting glob characters in testseq.

For the portable way to test if an string contains a substring, use:

file="JetConst_reco_allconst_4j2t.png";       testseq="gen"

[ "${file##*$testseq*}" != "$file" ] && echo True Substring is present

Or "${file##*"$testseq"*}" to avoid interpreting glob characters in testseq.

For the portable way to test if an string contains a substring, use:

file="JetConst_reco_allconst_4j2t.png";       testseq="gen"

[ "${file##*$testseq*}" ] || echo True Substring is present

Or "${file##*"$testseq"*}" to avoid interpreting glob characters in testseq.

added 11 characters in body
Source Link
user232326
user232326

For the portable way to test if an string contains a substring, use:

file="JetConst_reco_allconst_4j2t.png";       testseq="gen"

[ "${file##*$testseq*}" != "$file" ] ||&& echo True Substring is present

Or "${file##*"$testseq"*}" to avoid interpreting glob characters in testseq.

For the portable way to test if an string contains a substring, use:

file="JetConst_reco_allconst_4j2t.png";       testseq="gen"

[ "${file##*$testseq*}" ] || echo True Substring is present

Or "${file##*"$testseq"*}" to avoid interpreting glob characters in testseq.

For the portable way to test if an string contains a substring, use:

file="JetConst_reco_allconst_4j2t.png";       testseq="gen"

[ "${file##*$testseq*}" != "$file" ] && echo True Substring is present

Or "${file##*"$testseq"*}" to avoid interpreting glob characters in testseq.

Source Link
user232326
user232326

For the portable way to test if an string contains a substring, use:

file="JetConst_reco_allconst_4j2t.png";       testseq="gen"

[ "${file##*$testseq*}" ] || echo True Substring is present

Or "${file##*"$testseq"*}" to avoid interpreting glob characters in testseq.