joaotelles
asked on
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
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
ASKER
No... The beginning of each line can vary....
Tks,
Joao
Tks,
Joao
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.
If there is no way to identify a line which needs the "rtool -w " prefix, then it will be hard to automate this.
ASKER
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/ITerminalCapabili tiesCorbal oc" "corbaloc:iiop:iot-app-01: 10152/ris1 a/Tcr/ITer minalCapab ilities" -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
"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/ITerminalCapabili
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Tks.
sed 's/^"RIS"/rtool -w "RIS"/' file1 > file2