Mailing Attachments from the Terminal Prompt in UNIX and Linux

Transferring files from a UNIX or Linux server when FTP is not installed can be tricky. In my case, there was a set of log files that I needed to send to someone for analysis. After discovering that FTP was not set up on the server, I decided to try another route: zipping the logs into a single file and emailing the file to me.

First, I had to zip the files. The zip command was easy enough:

zip <zipped filename> <files to be zipped>

zipping files in UNIX

Next, I had to mail the zipped file. Fortunately, mailx was installed! Using this in conjunction with uuencode, and the file would be on its way.

uuencode <original filename> <final filename> | mailx -s <subject of email – put in quotes> <email address>

mailx example

Be sure to check your junk or spam folder, as email from the server could end up there.

Leave a Reply