sed error: “invalid reference \1 on `s’ command’s RHS”

Don’t you need to actually capture for that to work? i.e. for variant #2: -r -e “s/WARNING: (\([a-zA-Z0-9./\\ :-]\+\))/${warn}WARNING: \1${c_end}/g” \ (Note: untested) Without the -r argument back-references (like \1) won’t work unless each parenthesis is escaped with a \ character. With -r, argument back-references (like \1) won’t work unless the parenthesis are NOT escaped.

Command substitution: backticks or dollar sign / paren enclosed? [duplicate]

There are several questions/issues here, so I’ll repeat each section of the poster’s text, block-quoted, and followed by my response. What’s the preferred syntax, and why? Or are they pretty much interchangeable? I would say that the $(some_command) form is preferred over the `some_command` form. The second form, using a pair of backquotes (the “`” … Read more

bash : Bad Substitution

The default shell (/bin/sh) under Ubuntu points to dash, not bash. me@pc:~$ readlink -f $(which sh) /bin/dash So if you chmod +x your_script_file.sh and then run it with ./your_script_file.sh, or if you run it with bash your_script_file.sh, it should work fine. Running it with sh your_script_file.sh will not work because the hashbang line will be … Read more

JavaScript – Replace all commas in a string [duplicate]

The third parameter of String.prototype.replace() function was never defined as a standard, so most browsers simply do not implement it. The best way is to use regular expression with g (global) flag. var myStr=”this,is,a,test”; var newStr = myStr.replace(/,/g, ‘-‘); console.log( newStr ); // “this-is-a-test” Still have issues? It is important to note, that regular expressions … Read more

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