Timeline for Bash [[ test =~ regex ]] vs perl command result
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 23 at 12:47 | comment | added | hidigoudi | No problem, I understand, thank you for the vote up ! | |
Jan 23 at 11:44 | comment | added | rellampec |
Thanks @hidigoudi . The other answer (edited) offers a more complete explanation. I like of yours that went straight to address the target result, though. Here some reference on the bash if statements that explains the PCRE solution of the other answer. By the way, option -q (silent) gets to bring the exit status code to the if condition.
|
|
Jan 23 at 10:55 | history | edited | hidigoudi | CC BY-SA 4.0 |
added 319 characters in body
|
Jan 23 at 10:48 | history | edited | hidigoudi | CC BY-SA 4.0 |
added 130 characters in body
|
Jan 23 at 10:38 | comment | added | hidigoudi | Thank you ! It's done | |
Jan 23 at 10:37 | history | edited | hidigoudi | CC BY-SA 4.0 |
added 141 characters in body
|
Jan 23 at 10:08 | comment | added | rellampec |
Would select this as the best answer. Could you please align your answer with the question... the form is if [[ expression ]]; then ...; else ...; fi
|
|
Jan 22 at 22:22 | comment | added | glenn jackman |
Instead of the [ testing non-empty output from grep (unquoted is bad), use grep -q -- echo "$filename | grep -qP "$regex" && echo match || echo no match
|
|
Jan 22 at 19:34 | history | edited | hidigoudi | CC BY-SA 4.0 |
added 1 character in body
|
Jan 22 at 19:24 | history | answered | hidigoudi | CC BY-SA 4.0 |