[COLUG] Bash script trouble

William Yang wyang at gcfn.net
Thu Jan 31 08:21:40 EST 2008


Robert Grimm wrote:
> I'm trying to make a script that will list all email address from qmail 
> and include all forwarding addresses in the .qmail-* files. I want  
> every address to be a single line. What I end up with is something that 
> looks like this:

>                         #put target address after local address
>                         echo -n "->" >> ~/alladdresses
>                         cat $forward >> ~/alladdresses

I think the above code segment code will probably work better as:

	# put target after local address
	echo "-> `tr '[\015\012]' \\040 < $forward`" >> ~/alladdresses

You can sed/awk/tr away any characters you need to.  The text above would 
translate EOLs (CR, LF, CRLF) into white space, collapsing the entire file 
onto one line; it does need to be within the context of the echo command, 
however, of you'll not have an EOL on the line in ~/alladdresses.

Play with your backslashes; I may have the wrong number for your shell.

	-Bill

-- 
William Yang
wyang at gcfn.net


More information about the colug432 mailing list