LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-27-2011, 10:49 PM   #1
fundoo.code
LQ Newbie
 
Registered: Oct 2011
Posts: 5

Rep: Reputation: Disabled
Linux mail format problem


I am trying to use Linux mail command on red hat linux. It is working fine except when there is hardcoded "\n" characters in the file content i want to send. It is literally taking "\n" as text and message is not getting formatted to give newliine effect.

I am using the following command:

cat ${file-name} | mail -s "Sub" "a.b@c.com"

if the file is regular file with newlines, the output is fine.

But when "\n" is in the text... For Eg:

file contents are like:
ab\ncdefgh\n
add\nadda\n

then it is taking all those \n as characters and printing in the mail as it is. I was expecting it to format as newline as mailx does on solaris.

Please let me know my options.

I already tried:

echo -e
printf
 
Old 10-29-2011, 09:07 AM   #2
JSkywalker
Member
 
Registered: Aug 2007
Distribution: openSUSE 12.1
Posts: 96

Rep: Reputation: 24
Code:
cat ${file-name} | sed 's/\\n/\n/g' | mail -s "Sub" "a.b@c.com"
Its just replacing the '\n' with a newline....
 
Old 10-29-2011, 09:20 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Please, can you post the output of the following?
Code:
head $file-name | od -c
I'd like to see what is the actual format of the file. Does it actually contains newlines (other than the literal "\n") or is it a single line text file?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Conversion of voice mail into Asterisk voice mail format Terry56 Linux - General 6 11-14-2009 06:00 AM
problem with Evoution mail working with ubunto linux system senting mail dan1369 Linux - Newbie 1 06-14-2009 11:55 AM
Import Mail from /var/spool/mail (sendmail) to a MailDir Format in Postfix shawnbishop Linux - Software 0 04-06-2006 10:44 AM
Conversion of outlook .pst file into any Linux mail client format Mayuresh Linux - Software 1 08-09-2004 10:52 AM


All times are GMT -5. The time now is 06:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration