[PLUG-Devel] Process text records

Joey Prestia joey at linuxamd.com
Sat Nov 17 07:56:32 MST 2007


I am having problems trying to pull paragraphs out of a text file in 
bash. The text file is several hundred pages long and consists of 
paragraphs with newline characters. And the only thing I can use for a 
field separator is a blank line any ideas on how I be able to accomplish 
this? I have tried using sed and tr to process the file and basically 
tried this:

#!/bin/bash
sed 's/^$/@/g' text > text.out
for i in `seq 1 100` ; do
	cut -d@ -f$i text.out > string
	file=`cat string`
	echo $file | mail -s "Your data" user at domain.com
done

because of the newline characters I get bad results. I have been using 
README file in /usr/share/doc to try to get this right but the newlines 
throw the results wacky if I tr them out and if I leave them in the 
fields come up wrong because of the \n characters.

Thanks for your time.

-- 
Joey Prestia
Joey at linuxamd.com


More information about the PLUG-devel mailing list