New answers tagged sed
0
votes
Substitution in text file **without** regular expressions
Bash can do it!
zInput='string .* to .* search'
zMatch='.*'
zResult=''
while :; do
[[ "$zInput" =~ (.*)("$zMatch")(.*) ]] || break
zResult="replacement${BASH_REMATCH[3]...
3
votes
How do I delete every ocurrence of a word that is followed by another, without altering the whitespace?
With anything which supports perl-compatible regular expressions (PCRE), you can use a positive lookahead:
perl -pe 's/foo(?=.*bar)//' < txt
(?=) is a "zero-width positive lookahead assertion&...
3
votes
How do I delete every ocurrence of a word that is followed by another, without altering the whitespace?
OK, I found out how to do this. The command to do this with sed would be:
sed -i -E 's/foo([[:blank:]]*)bar/\1bar/' file
1
vote
Substitution in text file **without** regular expressions
After reading through the many answers here and not finding a straightforward way to do find + replace with string literals (not regular expressions) with sed / git grep:
I wrote a small CLI tool to ...
Top 50 recent answers are included
Related Tags
sed × 1023linux × 359
bash × 354
awk × 236
regex × 178
command-line × 142
grep × 120
unix × 77
shell × 64
shell-script × 43
find-and-replace × 42
perl × 39
macos × 36
text-editing × 32
bash-scripting × 31
script × 27
find × 24
csv × 23
vim × 22
windows × 21
ubuntu × 17
cygwin × 14
terminal × 13
string-manipulation × 13
rename × 11