Map the contents of three files!
Hi,
I wants to map the contents of three files and send them into one consolidated file. I have the following 3 files; # cat server abc01.example.com abc02.example.com abc03.example.com abc04.example.com abc05.example.com abc06.example.com abc07.example.com # cat status ACTIVE ACTIVE ACTIVE ACTIVE ACTIVE ACTIVE ACTIVE ACTIVE # cat buildDate 2017-02-16T14:51:28Z 2017-05-22T08:10:01Z 2017-06-01T12:40:28Z 2017-05-09T12:47:04Z 2017-05-09T10:21:22Z 2017-05-08T09:26:06Z 2017-04-24T11:08:03Z I wants to achieve something similar as follows, abc01.example.com#ACTIVE#2017-02-16T14:51:28Z abc02.example.com#ACTIVE#2017-05-22T08:10:01Z abc03.example.com#ACTIVE#2017-06-01T12:40:28Z abc04.example.com#ACTIVE#2017-05-09T12:47:04Z abc05.example.com#ACTIVE#2017-05-09T10:21:22Z abc06.example.com#ACTIVE#2017-05-08T09:26:06Z abc07.example.com#ACTIVE#2017-04-24T11:08:03Z I try with the following loop, but not working; for i in `cat server` do for j in `cat status` do for k in `cat buildDate` do cat $i $j $k > /tmp/output done done done Could you please help to achieve the goal! Regards. |
Hi. Recommend you use [code][/code] tags around your code.
Instead of using cat to output these variables to the temp output file, have you tried to use "echo"? |
Greetings AR.
* Please note that this section is only for intros. * Edit: Thread was since moved from Member Intro section. |
Welcome to LQ!
To get better exposure your post has been moved to the Programming forum where it is more appropriate. As already suggested, please place your code snippets inside [CODE]...[/CODE] tags for better readability. You may type those yourself or click the "#" button in the edit controls. Finally, also as suggested by rtmistler, your loop code is nearly sufficient, but in the output line you should use echo or printf instead of cat, along with some formatting to get the desired result. With echo you will need to insert the # separators shown in your example, or with printf put them in the format string. |
Quote:
Code:
paste -d# $Server $Status $Build >$OutFile Code:
abc01.example.com#ACTIVE#2017-02-16T14:51:28Z . |
It's working! Thanx Martin!
|
Thank You all for such quick response!
|
All times are GMT -5. The time now is 03:56 AM. |