Shell - appending string at beginning of each text file line

Hi,

I have a text file that has very long string in each line that go through another line as shown below...

"RIS" -inst="ris1a" "Corba/OAIAddr" "demo-app-01" -type=STRING -description="The hostname or ip address for the machine on which RPAOSNIS is running." -visibility=INSTANCE

So, I have to append  a string at the beginning of each line (rtool -w)..

The file has many lines so I come up with this command:
sed "s/^/rtool -w /" file_1 > file_2

But file_2 is getting the rtool -w in all the lines... whenever there is a break in the line...

rtool -w "RIS" -inst="ris1a" "Corba/OAIAddr" "demo-app-01" -type=STRING -description="The hostname or ip address for the machine on which
rtool -w RPAOSNIS is running." -visibility=INSTANCE

===

Is there anything to prevent it?

Tks,
Joao
joaotellesAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

simon3270Commented:
Do all of the lines you want to change start with "RIS"?  If so

    sed 's/^"RIS"/rtool -w "RIS"/' file1 > file2
0
joaotellesAuthor Commented:
No... The beginning of each line can vary....

Tks,
Joao
0
simon3270Commented:
But is there some consistency?  Is it always a double quote folowed by capital letters followed by another double quote?  is there always a '"-inst=" bit immediately following the first word?

If there is no way to identify a line which needs the "rtool -w " prefix, then it will be hard to automate this.
0
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

joaotellesAuthor Commented:
Here are more lines of the file that might answer your questions.

"JamAssistant" -inst="jamat1a" "Sso/Service/BaseUrl" "https://iot-app-01:8443/jamassistant" -type=STRING -description="The base URL of the application" -visibility=INSTANCE
"JamServer" -inst="jam1a" "Network/HostName" "iot-app-01" -type=STRING -description="The hostname or IP-address for the machine on which the JamServer is running." -visibility=INSTANCE
"Mdm" -inst="mdm1a" "Network/HostName" "iot-app-01" -type=STRING -description="The hostname or ip address for the machine on which MDM is running. All processes acting as clients to MDM shall use t
his parameter." -visibility=INSTANCE
"SmartManage" -inst="sm1a" "Network/HostName" "iot-app-01" -type=STRING -description="The hostname or ip address for the machine on which SmartManage is running. All processes acting as clients to
SmartManage shall use this parameter." -visibility=INSTANCE
"RIS" -inst="ris1a" "Network/ITerminalCapabilitiesCorbaloc" "corbaloc:iiop:iot-app-01:10152/ris1a/Tcr/ITerminalCapabilities" -type=STRING -description="Corbaloc object reference to Terminal Capabil
ities API-object, automatically assigned by the server." -visibility=INSTANCE
"TransportServer" -inst="ts1a" "Network/HostName" "iot-app-01" -type=STRING -description="The hostname or ip-address for the machine on which the Transport server is\nrunning. All processes acting
as clients to the Transport Server use this\nparameter." -visibility=INSTANCE
"WigServer" -inst="wig1a" "Network/HostName" "iot-app-01" -type=STRING -description="The hostname or ip-address for the machine on which the Wig server is running." -visibility=INSTANCE
0
simon3270Commented:
It looks as though they all start
  "SeriesOfLetters" -inst=

so the sed could be
sed 's/^\("[^"]*" -inst=\)/rtool -w \1/'

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
joaotellesAuthor Commented:
Tks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.