How to substitute text from files in git history?

I’d recommend using the BFG Repo-Cleaner, a simpler, faster alternative to git-filter-branch specifically designed for rewriting files from Git history. You should carefully follow these steps here: https://rtyley.github.io/bfg-repo-cleaner/#usage – but the core bit is just this: download the BFG’s jar (requires Java 7 or above) and run this command: $ java -jar bfg.jar –replace-text replacements.txt … Read more

sed substitution with Bash variables

Variables inside ‘ don’t get substituted in Bash. To get string substitution (or interpolation, if you’re familiar with Perl) you would need to change it to use double quotes ” instead of the single quotes: # Enclose the entire expression in double quotes $ sed “s/draw($prev_number;n_)/draw($number;n_)/g” file.txt > tmp # Or, concatenate strings with only … Read more

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