regex


Replace a line in the file using sed, line has a moving portion in the center of it


There is a moving portion in the line.
sed needs to search for a line that might have anything in the center of it.
In other words we are looking to find this line by telling sed that it starts with
aaa
and ends with
ccc
the center could be anything.
Let's say we have a file called a.txt, and this is what is in it.
a
b
aaa111ccc
sed needs to find the line that looks like..
aaa(.*)ccc
And then replace it with
"_TEST_"
The output should be aaa_TEST_bbb
Which part do you need help with?
sed 's/^aaa.*bbb$/aaa_TEST_bbb/' file >newfile
If you want to edit the file in place, remove the redirection and add a suitable -i option (provided your sed supports it).

Related Links

Given a certain regex pattern, re-arrange and manipulate the contents of a cell
Regular expression“\\|” in strsplit
Parsing sectioned file with augeas
I need search a pattern in a header line of my file and concatenates the next line with Perl
Regular Expression statement to replace text inside two literals
RegEx pattern with not followed by
How to pull words based on positioning from a text element using Regex?
Remove C/C++, Multiline comments from a array in which file is read
Regexp match time expression (mmmm:ss)
How do I create a regex in Emacs to capture text between double square brackets?
How to set a RegExp to have a real matching judgement?
Editing a line of a configuration file from shell
Perl replace the top-level numbers only from a tree
Regular Expressions match exactly 7 or 9 digits
How to accept numbers and specific words?
Javacc regular expression that matches all string except certain ones

Categories

HOME
azure
validation
mocking
f#
bootstrap-4
identityserver4
office-js
lua
dicom
performance-testing
azure-search
ssl-certificate
compiler-errors
react-navigation
backand
linear-programming
wikipedia
go-gorm
asp.net-mvc-3
zipfile
square-connect
pymc3
executable
jsqmessagesviewcontroller
next
round-robin
thrift
ssms-2014
cadvisor
mediator
naturallyspeaking
google-oauth2
azure-redis-cache
parallax
code-signing
icloud-drive
scalability
temp
json-c
jtapi
microsoft-translator
response
windows-scripting
compass-lucene
essbase
polymer-cli
edeliver
nexus-5
quicksand
mediawiki-api
win2d
zuul
uservoice
sharpziplib
gcc4.8
database-cleaner
hipi
replicate
xceed
business-logic
heritrix
vlc-android
qlpreviewcontroller
gcloud-java
occam-pi
administrator
clientid
oracle-bi
wt
voting
base-conversion
windows-universal
llvm-gcc
gcovr
razor-2
catalina.out
syndication-feed
spread-toolkit
short
nhunspell
deepzoom
inputview
freemind
str-to-date
nsusernotificationcenter
nsimageview
xhtml-transitional
scrollpane
geometry-surface
route-me
neventstore
tempo
icon-fonts
memento
cloud-hosting
eject
doophp
program-files
mdi
process.start
datatemplate
alivepdf
xoom
program-transformation
webshop
cracker
run-length-encoding
virtual-server
shareware

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App