![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| "sed" to check file size & echo " " to destination file | jockey007 | Shell Programming and Scripting | 7 | 04-28-2009 03:08 AM |
| VMDB Failure" followed by "Unable to open snapshot file" | s_linux | SuSE | 0 | 02-10-2009 12:01 PM |
| How to cut a file using " ", but fields can be separated with more than one " " | shira | Shell Programming and Scripting | 12 | 01-26-2009 04:45 PM |
| Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" | iBot | UNIX and Linux RSS News | 0 | 01-04-2008 03:00 PM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 01:52 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I have a file that has fields with text "folded" over more than one line. I'd like to parse the file for information, however I need to "unfold" it first. My gut tells me that sed is the command to use, however trying to make it work modifying examples I have found here is just not working. And I just know it must be the simplest thing in the world! How do I unfold my file using sed??? A folded line is a line with a field of information that has been purposely broken across multiple lines. A CRLF is followed by a single space on the next line. Anyone up for showing a newbie how green he is? EDIT: More Information --- The desired output would be when sed takes any line that begins with a single whitespace and combines it with the previous line (ie unfolding it). Below I have provided two examples. "Folded" line: --- Code:
DESCRIPTION:Lorem ipsum dolor sit amet\, consectetuer adipiscing elit\, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat v olutpat. Ut wisi enim ad minim veniam\, quis nostrud exerci tation ullamcor per suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem v el eum iriure dolor in hendrerit in vulputate velit esse molestie consequat \, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. "Unfolded" line: --- DESCRIPTION:Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Too Much Information: --- As more of a learning project, I am writing a script that looks at my gCal calendar and creates a time sheet of my activities. I am downloading the calendar on demand from Google using curl. I am also downloading from my own private website a client table, and a job table. Using awk and grep I am parsing information from all three files and creating text files (work reports, invoices, etc.) I "think" I already have the code to identify events, allocate ISO week numbers, extrapolate event data, do date/duration calculations, do cost calculations and output the results to a text file. A useful application that enables me to learn more about scripting and saves me time in the process. I would like to be able to parse the DESCRIPTION field for information I might add to the event while I am out on my iPhone (job code, client code, rate code, materials, etc.) and have the final output adjusted accordingly. The problem is that in an ics file any field over 75 octets is "folded". "That is, a long line can be split between any two characters by inserting a CRLF immediately followed by a single linear white space character (i.e., SPACE, US-ASCII decimal 32 or HTAB, US-ASCII decimal 9). Any sequence of CRLF followed immediately by a single linear white space character is ignored (i.e., removed) when processing the content type." That's from From RFC2445. The first goal is to have a csv file that I can stick into Excel, Word, Pages. There will be an immediate time saving from manually creating time sheets. I am almost there already. The second goal is to use groff to automatically create a PDF with a logo. If the results are accurate, I could just have it automatically email them to clients once a week. The third goal is to use cgi scripting and Apache to create a simple web page that will let me generate a work report or an invoice based on some basic information that a user provides (date range, client, etc.) I could then create invoices on the fly or even have clients generate their own work reports. Maybe have another page that allows me to edit the client and job tables... But now I am getting waaaaaaaay ahead of myself. Last edited by Franklin52; 04-05-2009 at 09:24 AM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|