I have a file which contains a set of similar lines, as follows:
Remedy Support Action Triggered by Incident Modification of type: ARA username2 ########## ARA|INC0000178532 INC0000178532 0000000019879 000000000038372
Remedy Configuration & Maintenance Action Triggered by Incident Modification of type: ARA username1 ########## ARA|INC0000085423 INC0000085423 0000000000073 000000000054
I want to cut each column of each line and store in a variable which will be used to pass to another script with these variables as parameters. Something like follows:
var1 = Remedy Support
var2 = Action Triggered by Incident Modification of type: ARA
var3 = username2
var4 = ##########
var5 = ARA|INC0000178532
var6 = INC0000085423
var7 = 0000000019879
var8 = 000000000038372
Then , pass these variables to another script as parameters.
Likewise, i want to do this fo each line in file; this will need loop i suppose. (How to achieve this?)
Can you please help how do i achieve this cut, storing in variable and passing these as parameters to another script?
var1=Remedy Support
var2=Action Triggered by Incident Modification of type: ARA
var3=username2
var4=##########
var5=ARA|INC0000178532
var6=INC0000178532
var7=0000000019879
var8=000000000038372
var1=Remedy Configuration & Maintenance
var2=Action Triggered by Incident Modification of type: ARA
var3=username1
var4=##########
var5=ARA|INC0000085423
var6=INC0000085423
var7=0000000000073
var8=000000000054
EDIT: Following is the non one-liner solution for same.
Actually, the data that we will get would be run time data. And the first two columns namely var1 and var2 are highly unprdedicatble since these will be combination of various words. So I tried all possible combinations i knew but couldnt achieve this. Hope, this code works for all kinds ofvar1 and var2.
Now since, we have acheived this, I wanna know how can i use these variables to pass as parameters to another script? I dont know such advanced UNIX.. so can you please help me out..
---------- Post updated at 07:51 AM ---------- Previous update was at 07:37 AM ----------
One more requirement:
As in the code above, i want the varaibles to be reused in another script, so i cant get them printed on command prompt. I would like them to store somewhere where i can reuse them. So how can the above code be modified?
The code runs perfectly for as many as lines i enter! Thanks a lot lot!
cat Output_file
var1=Remedy Support
var2=Action Triggered by Incident Modification of type: ARA
var3=username2
var4=##########
var5=ARA|INC0000178532
var6=INC0000178532
var7=0000000019879
var8=000000000038372
var1=Remedy Configuration & Maintenance
var2=Action Triggered by Incident Modification of type: ARA
var3=username1
var4=##########
var5=ARA|INC0000085423
var6=INC0000085423
var7=0000000000073
var8=000000000054
Now if you want to call these variables into a new script as variable pass, you can use it but it will be little tricky one as per your requirement we need to always print variables from var1 to var8 only so there will be duplicate entries in output file, if you can open your requirement little broader it will be better for us to understand and help you, hope this helps.