Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-03-2014, 11:06 AM   #1
kannan radhakrishnan
LQ Newbie
Registered: Dec 2014
Posts: 2

Rep: Reputation: Disabled
linux commands

Hi all,
I m new to shell scripts and I came across few commands which I didn't understand. Please can you explain to me about this.

cat - filename <<Here | sendemail -iot
From: xyz
To: xyz
Subject: xxxxx
Content-type: text/html; charset-us-ascii
Content-transfer-encoding: 7bit
mime-version: 1.0

. I can understand tat send email is usig for sending the contents in the file. The file contains html the end an proper email is sent with all the details in tje file.
My doubt is why is it not working with a normail mail command. Also what is 'here' in the content above. And also y there is a - after cat. Appreciate your help.
Old 12-03-2014, 09:22 PM   #2
Registered: May 2012
Location: Sebastopol, CA
Distribution: Slackware
Posts: 543
Blog Entries: 22

Rep: Reputation: 560Reputation: 560Reputation: 560Reputation: 560Reputation: 560Reputation: 560
cat will iterate through its arguments and write their contents to stdout.

In your example, its arguments were "-" and "filename".

cat understands "-" to represent its own stdin. "cat -" will read content from its stdin and write it to its stdout until there is no more data available from stdin.

So in your example, cat first reads content from stdin, and writes it to stdout, then reads content from "filename", and writes it to stdout.

"<< Here" is a bashism for reading text from the following lines up to "Here" (alone on its own line) and writing it to the stdin of the command to its left (in this case the cat command).

Open the bash man page and skip to the "Here Documents" section to read more about this feature:

As for why sendemail vs mailx, I would assume it is used so the email's headers could be given to it via stdin, but I'm not sure.
Old 12-04-2014, 02:37 AM   #3
kannan radhakrishnan
LQ Newbie
Registered: Dec 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks a bunch !!
That was a spot on reply that i expected !!
thanks again


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
USB Low Level commands (embedded Linux, terminal commands) JonCombat Linux - Newbie 2 01-05-2013 02:34 PM
Need help for Windows cmd commands into Linux terminal commands. windowsNilo Linux - Software 2 07-02-2008 06:26 PM
Need help for Windows cmd commands into Linux terminal commands. windowsNilo Linux - General 2 07-01-2008 06:53 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:09 PM.

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