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?
 
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
 
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
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
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
 
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
 
joaotellesAuthor Commented:
Tks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.