Basic formatting. sed, or cut, or what?

Posted by dsclough on Stack Overflow See other posts from Stack Overflow or by dsclough
Published on 2013-06-28T21:24:01Z Indexed on 2013/06/28 22:21 UTC
Read the original article Hit count: 141

Filed under:
|
|
|

Very new to this whole Unix thing. I'm currently using korn shell to try and format some lines of text.

My input has a couple of lines that look something like this

Date/Time        :- Monday June 03 00:00:00 EDT 2013
Host Name        :- HostNameHere
PIDS             :- NumbersNLetters
Product Name     :- ProductName

The desired output would be as follows:

Date/Time="Monday June 03 00:00:00 EDT 2013" HostName="HostNameHere" PIDS="NumbersNLetters" ProductName="ProductName"

So, I need to get rid of any spaces in the leftmost column, and throw everything in the rightmost column between quotations. I've looked at the cut command, and got this far:

Cut -f 1,2 -d -

Which might produce a result like Date/Time:Monday June 03 00:00:00 EDT 2013, which is close to what I want, but not quite. I wasn't sure if cut could let me add parentheses, and it doesn't look like I can remove spaces that way either.

sed seems like it might be closer to the answer, but I wasn't able to find through googling how I might just look for any pattern and not a specific one. I apologize for the incredibly basic question, but reading documentation only gets you so far before your brain starts to ache... If there are any better resources I should be looking at I would be happy to get pointed in the right direction. Thanks!

© Stack Overflow or respective owner

Related posts about shell

Related posts about sed