Showing us a single line of input and a single line of output while talking about multiple occurrences of a pattern that may repeat on multiple lines leaves a lot to the imagination.
Do you just want to change ABC for A to row for a as shown in your example? Are there other strings that you want to change? Can these three word sequences appear multiple times on a single line? Can these three words be split across lines for a singe occurrence?
What operating system are you using? Are we restricted to a certain shell or set of tools to be used to solve this problem?
For what you have shown us, the much simpler command:
does everything you've shown us needs to be done.
This User Gave Thanks to Don Cragun For This Post:
Somehow i doubt that. If you want to find the version information do a oslevel -s. Fortunately, your question is not related to the OS version at all, see below.
Quote:
Originally Posted by sheetal.arun
We have a database export file which needs to be formatted as below
Output
To solve such problems it usually helps to rephrase the requirements.
As far as i can see, you want to concatenate every line following an empty line until you hit a blank line. Then print everything in one line, up to the "select"-statement and in a second separate line the statement itself. Here we go. The following is a commented version, remove any comment and the trailing blanks in each line before running it:
save that to a file and issue:
If you want to include additional changes to your text (inserting words, lowercasing, uppercasing, ... add the respective rule between these two lines:
Requirement: Replace content between 'Locking' and 'Access' with 'Locking row for access'
The code in opening post tries to do that, but it ends up taking the first 'Locking' and last 'Access' and replace that as an entire pattern, due to use of .*
Since, there are multiple create view commands in the file (as seen in the input) and each needs to replace seperately
We have a workround where we pass each create command to a file and then run code on that individually. We were looking for a more effecient replace.
Hello.
A find command return a list of file.
For each fileReplace the content starting with the first "§" (of two) ending with last "ɸ" (of two), regardless of the content ( five lines )
by the following content (exactly) :
§2019_08_23§ #
# ... (8 Replies)
As per my requirement, I need to get a multiline input. It can be stored in a file, that's not a problem. User will be prompted to enter steps. he should able to enter the steps in multiple lines by pressing enter.
All I know in read command that reads the input till we press enter. Can someone... (5 Replies)
Experts,
I am novice unix user. At my work, most of our DBA's work on creating DDL's to create new tables in production. At every week we need to validate the scripts (do peer review) and it takes a while and also it is not effective when we have like 150 tables created in the scripts. I am... (3 Replies)
Hey everyone, I'm new to sed and I need to create a script for inserting one line of code at the beginning of every method in a Xcode project (over 6,000 methods). Each method Structure is
(+ or -) (Various declarations-- could span multiple lines) ({)
I've tried for days, any guidance would be... (2 Replies)
Hi all
I have data files which contain data as shown below:
Line 5: FIDE
INST_DESC: DIAM Co Ltd/Japan => MAID Co Ltd/Japan
INST_NME: DIAM Co Ltd/Japan => MAID Co Ltd/Japan
Line 6: FIDE
INST_DESC: DIAM DL/Pimco US Bond Open Born in the USA => MAID DL/Pimco US Bond Open Born in the... (6 Replies)
Hi there
I just wondered if someone could give me some perl advice
I have a bunch of text files used for a wiki that have common headings such as
---++ Title
blah
---++ Summary
blah
---++ Details
Here is the multiline
block
of text I
wish
to (6 Replies)
Hi,
I am a newbie to shell scripting and to Linux environment as well.
In my project I am trying to search for following text from the httpd.conf file
<Directory '/somedir/someinnerdir'>
AllowOverride All
</Directory>
and then remove this text and again rewrite the same text.
The... (1 Reply)
I have a data of the form
0.0117843924 0. 0. 0. 0.
0.011036017 0. 0. 0. 0.
0.0103351669 0. 0. 0. 0.
4839.41211 0. 0. 0. 0.
4532.08203 0. 0. 0. 0.
I would like to insert a couple of blank lines before the 4839 line, every time it appears. The numbers in the... (2 Replies)
How does one do a search for a multiline regular experssion and output the results to a file.
I know this won't work since grep only searches single lines:
egrep '<a>.*?</a>' source.xml > output.xml
Here are some sample patterns I'd like to match and output to a single file:
... (4 Replies)