Pattern to get string between two specific words/characters using grep [duplicate]

Using grep -oP: s=”<some text> [email protected], <some text>” grep -oP ‘(?<=from=).*?(?=,)’ <<< “$s” [email protected] OR else avoid lookbehind by using \K: grep -oP ‘from=\K.*?(?=,)’ <<< “$s” [email protected] In case your grep doesn’t support -P (PCRE) use this sed: sed ‘s/.*from=\(.*\),.*/\1/’ <<< “$s” [email protected]

Unix Command to List files containing string but *NOT* containing another string

Try this: grep -rl <string-to-match> | xargs grep -L <string-not-to-match> Explanation: grep -lr makes grep recursively (r) output a list (l) of all files that contain <string-to-match>. xargs loops over these files, calling grep -L on each one of them. grep -L will only output the filename when the file does not contain <string-not-to-match>.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)