[clue-tech] Parsing text editor wanted

Kevin Cullis kevincu at orci.com
Sat Jul 29 09:47:08 MDT 2000


OK, something new to learn, sed.  It'll take me a while to figure it
out, but I'll cut and paste that command stuff without modification and
see what happens.  I'll let you know how it works.

Kevin

Lynn Danielson wrote:
> 
> Kevin Cullis wrote:
> >
> > I'd like to parse text which has been cut and pasted from the Net into a
> > text file to be uploaded into a spreadsheet/database. While vi works,
> > the problem is multiple spaces to be deleted between the fields of text
> > to be imported.  The basic issue is a find and replace with a replace
> > all to remove the multiple spaces.
> 
> One possible solution is to use tr and sed.  If you've pasted your
> text into a file you can then cat that file through tr and sed and
> redirect the output to another file.  For example, if you've saved
> your captured text in file1 and would like all of the spaces between
> words taken out and replaced with commas, you could do the following:
> 
>   cat file1 | tr -s " " | sed -e 's/ /,/g' > file2
> 
> The tr squeezes out the extra "space" characters, then sed
> substitutes commas for the remaining spaces.  A simpler way to
> see how this works is to use it on a long directory listing:
> 
>   ls -l | tr -s " " | sed -e 's/ /,/g'
> 
> This will only give you your desired result if you want every
> word delimited by commas instead of spaces.  I'm sure a more
> comprehensive and elegant solution is available using perl or
> python and regular expressions.  Let me know if this works for
> you.
> 
> Lynn
> _______________________________________________
> CLUE-Tech mailing list
> CLUE-Tech at clue.techangle.com
> http://clue.techangle.com/mailman/listinfo/clue-tech

-- 
Kevin
--
Success is never final, failure is never fatal.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kevincu.vcf
Type: text/x-vcard
Size: 206 bytes
Desc: Card for Kevin Cullis
Url : http://cluedenver.org/pipermail/clue-tech/attachments/20000729/7b24c6d6/kevincu.vcf


More information about the clue-tech mailing list