Command line question

Issues related to applications and software problems
Post Reply
ostene
Posts: 48
Joined: 2015/01/25 16:10:17

Command line question

Post by ostene » 2022/06/20 07:55:30

Hello,

In the "Linux Bible" Tenth Edition page 100
I tried an example that I don't understand:

$ mail root < ~/.bashrc

Can someone please tell me!
Thanks ostene

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Command line question

Post by jlehtone » 2022/06/29 14:15:17

Command mail root runs program, mail, with one command-line parameter "root".
man mail wrote:To send a message to one or more people, mailx can be invoked with arguments which are the names of people to whom the mail will be sent. The user is then expected to type in his message, followed by an `control-D' at the beginning of a line.
Therefore, the command starts 'mail', tells it that TO-address of message will be "root", and starts to read the message text from standard input.

However, in this case we do not type the message. We redirect the content of a file into standard input of 'mail'. That is, we tell the bash to redirect (the <) the text in file "~/.bashrc" into the standard input of 'mail'.

In short, we send the content of file "~/.bashrc" as mail message to account "root".

Post Reply