Re: tr syntax

From: E Arredondo (atk_at_sbcglobal.net)
Date: 05/31/05


Date: Tue, 31 May 2005 16:27:46 GMT


"John DuBois" <spcecdt@armory.com> wrote in message
news:119ejq3b7mr18c6@corp.supernews.com...
> In article <9wGle.2067$rY6.354@newssvr13.news.prodigy.com>,
> E Arredondo <atk@sbcglobal.net> wrote:
>>I can't sed my file because I found out that, after I receive the data
>>from
>>a http call and then *cat*ing it to a file from a cgi-bin script it makes
>>a
>>file like this whit the message "Incomplete Last line" and neither *tr* or
>>*sed* would work unless I *vi* the file and then save the file to get rid
>>of
>>that message "Imcomplete last line", then tr and sed will work fine:
>>How can I fix this issue with the "Incomplete last line" ?
>
> tr should work fine. sed does insist on a trailing newline. You can do:
>
> { cat file; echo ""; } | sed ...
>
> to append a newline to its input. Or use awk, which doesn't have this
> problem;
> replace
>
> sed 's/foo/bar/'
>
> with
>
> awk '{sub(/foo/,"bar")}1'
>
> John
> --

My script is working now but I was just wondering if there's a way to
compress the sed into 1 line to make it simpler to save some milliseconds or
maybe seconds of processing time, Does it accepts semi colons or commas
between searches ?, here's what my final script looks like, :

-------------begin here --------------------
FILE=/usr2/appl/fpmerge/cq$$.txt
FILE2=/usr2/appl/fpmerge/cqa$$.txt
cat > $FILE
echo >> $FILE

sed -e "s/%7E/\~/g" < $FILE > $FILE2
sed -e "s/%3A/\:/g" < $FILE2 > $FILE
sed -e "s/%0D%0A/\|/g" < $FILE > $FILE2 # this will let tr down below
change all |'s for LF's
sed -e "s/+/ /g" < $FILE2 > $FILE
sed -e "s/%28/\(/g" < $FILE > $FILE2
sed -e "s/%29/\)/g" < $FILE2 > $FILE
cat $FILE | tr "|" "[\012*]" > $FILE2

------------cut here-------------