Dir Path 1
Connection pool="somename"; "DataSource Name"="DS name"; Password="pwd"; User Id="uid";some other fields
Dir Path2
Password="pwd2"; User id="uid2"; Connection pool="somename2"; "datasource name"="DS name2";some other fields.
Under each dir path i can have multiple lines
My task is to print dir path & below only Data source name & user Id, these field names are case sensitive like DataSource or datasource, occurances are not symmetric, i meant DataSource field can be 1st or any field.
I want o/p like
Dir path1
"DataSource Name"="DS name1" "User Id"="uid1"
Dir path2
"datasource name"="DS name2" "User Id"="uid2"
Work fine at home with input example (gnu sed 4.2.1):
$ cat dir_path
Dir Path2
Password="pwd2"; User id="uid2"; Connection pool="somename2"; "datasource dame"="DS name2";some other fields.
Dir Path 1
Connection pool="somename"; "DataSource Name"="DS name"; Password="pwd"; User Id="uid";some other fields
$ sed 's/^.*[^"]\("*user id[^;]*;\)/ \1&/i;s/^.*[^"]\("*datasource name[^;]*\)/\1&/i;s/\([^;]*\);.*/\1/' dir_path
Dir Path2
User id="uid2"
Dir Path 1
"DataSource Name"="DS name" User Id="uid"
What i meant duplicate means, dups between Dir Path, like under Dir Path2 there are 3 common entries, i need to print only once
Your code is removing dups overall.
cat dir_path
Dir Path1
Password="pwd2"; User id="uid2"; Connection pool="somename2"; "datasource same"="DS name2";some other fields.
Dir Path 2
Connection pool="somename"; "DataSource Name"="DS name"; Password="pwd"; User Id="uid";some other fields
Connection pool="somename"; "DataSource Name"="DS name"; Password="pwd"; User Id="uid";some other fields
Connection pool="somename"; "DataSource Name"="DS name"; Password="pwd"; User Id="uid";some other fields
Dir Path 3
Connection pool="somename"; "DataSource Name"="DS name3"; Password="pwd3"; User Id="uid3";some other fields
Connection pool="somename"; "DataSource Name"="DS name3"; Password="pwd3"; User Id="uid3";some other fields
& also is there a way to print
Dir path in one column & other entries in other column