Linux: why colon (:) is removed from the file name when using uuencode?

291 Views Asked by At

I am trying to e-mail a file containing colon (:) character in the name:

my_attachment_name=some_file_with_:_in_the_name.txt
uuencode "${my_attachment_name}" "`basename \"${my_attachment_name}\"`"
     | mail -s "My Report ..." [email protected]

But, when I receive the e-mail, I see ":" has been removed from the file name.

some_file_with__in_the_name.txt

How can I fixed it?

Thanks.

1

There are 1 best solutions below

2
On

You might try using uuencode with "--encode-file-name". However, here, I'm seeing:

$ uuencode foo:bar.txt foo:bar.txt
begin 664 foo:bar.txt
#:&D*
`
end

which is exactly what I'd want in the "begin" line.

In contrast:

$ uuencode --encode-file-name foo:bar.txt foo:bar.txt
begin-encoded 664 Zm9vOmJhci50eHQ=
#:&D*
`
end

uudecode doesn't require any options to be able to reconstruct foo:bar.txt from Zm9vOmJhci50eHQ= on my computer.

Check the raw content of your email too, it's possible the email client is being stupid. A DOS bias, for example, could make an email client ditch colons.