03-12-2008
Quote:
Originally Posted by
tragic54
I was wondering what command lines i could use to do the following.
1. mail a file to a user with a subject line "HELLO". Also, send a Blind carbon copy to a different user?
2. Display the number of files AND directories in a given directory?
3. Display the last 5 files in a given directory?
I've searched all the manual pages i could possibly think of and i can't seem to find the answers to these. Thanks!
Ans(Q1) :
mail -s HELLO
person1@domain.com -b
person2@domain.com <file.txt
(This will send the contents of the file as mail contents to person1 and blind carbon copies to person2)
uuencode file.txt file.txt | mail -s HELLO
person1@domain.com -b
person2@domain.com
(this will send the file as attachement to person1 and blind carbon copy to person2.Attachment can be send if and only if the file is encoded)
Ans(Q2) :
ls -Rl | awk 'BEGIN{d=0;f=0;l=0;}{if(/^d/){d++}else if(/^-/){f++}else if(/^l/){l++}}END{print "Directories: "d "\nFiles: " f "\nLinks: " l}'
Ans(Q3) :
ls | tail -5
(List the last five files in a directory)
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
i.e configuration of C compiler :confused: (4 Replies)
Discussion started by: atiato
4 Replies
2. Tips and Tutorials
A
at : execute commands at a specified time/date.
awk: a scripting language, especially useful for manipulating text and automation.
B
bash : invokes the Bourne Again Shell (standard on most boxes).
batch: execute comands when load permits.
bc : interactive C-like calcultor (integers... (6 Replies)
Discussion started by: binhnx2000
6 Replies
3. Shell Programming and Scripting
Hi there,
I am looking to create a single file called outputa.txt, which will show the contents of my directorya and its sub directories, and all file and directory permissions.
What command would be used for this?
Cheers
Kev (2 Replies)
Discussion started by: kev112
2 Replies
4. UNIX for Dummies Questions & Answers
Hi Group ,
I m trying to execute commands on some other system using write command but inspite of executing the commands they r passed as simple messages.
- i m writing
>write user-id
! ls
o
ctrl-d
inspite of executing the command ls,other terminal shows ! ls.
Thnx in advance. (2 Replies)
Discussion started by: Aashish
2 Replies
5. UNIX for Dummies Questions & Answers
echo -n "1. Updating Password Policy in OID..." | tee -a $logfile
set ldap_v1 = `ldapsearch -b "" -h $oid_host -p $oid_port -D "cn=orcladmin" -w $admin_pwd -s sub "cn=PwdPolicyEntry" dn | head -1`
echo "dn:$ldap_v1" > ldap1.out
echo "changetype:modify" >> ldap1.out
echo... (2 Replies)
Discussion started by: maoro
2 Replies
6. UNIX for Dummies Questions & Answers
cdfcxvvbbvnbjmjnhjml. (1 Reply)
Discussion started by: sree11
1 Replies
7. Shell Programming and Scripting
Hi Gurus
I am very new to Unix Shell Prog. I have a file in format
Q1 Dirname-FileName Score Remarks
i.e. containing columns separated by space. I want to read Column 1 and 2 and then join them to make a string that would be a path to a file. I will use this string to fetch the files and... (4 Replies)
Discussion started by: kimskams80
4 Replies
8. UNIX for Dummies Questions & Answers
i have two requirement
a file1 has field CNT=1000
i want to take count on file2 which can be like 2000
and replace in file1 so it becomes CNT=2000
a file1 has field TSTMP=2008-11-06-15.54.20.000000
i want to take the file creation date on file2 which can be like... (1 Reply)
Discussion started by: er_zeeshan05
1 Replies
9. UNIX for Dummies Questions & Answers
I need two solutions
1) How can i swap the first and last character in each line of file temp
2) How can i display content of the file using sed command
Please help (2 Replies)
Discussion started by: champu
2 Replies
10. Shell Programming and Scripting
I am new to unix so this is probably a pretty basic question.
I am trying to write several commands on one line that creates a directory called bf in the current directory, then copy all files within that directory and any subdirectories, that do not start with the letter c to the new bf folder.... (5 Replies)
Discussion started by: scotty85
5 Replies
LEARN ABOUT REDHAT
mhmail
MHMAIL(1) [nmh-1.5] MHMAIL(1)
NAME
mhmail - send or read mail
SYNOPSIS
mhmail [addrs ...] [-body text] [-cc addrs ...] [-from addr] [-subject subject] [-version] [-help]
DESCRIPTION
mhmail is intended as a replacement for the standard Berkeley mail program (mail or mailx), which is compatible with nmh. This program is
intended for the use of programs such as cron, which expect to send mail automatically to various users. It is also used by various nmh
commands to mail various error notifications. Although mhmail can be used interactively, it is recommended that comp and send be used
instead to send messages.
When invoked without arguments, it simply invokes inc to incorporate new messages from the user's maildrop. When one or more users is
specified, a message is read from the standard input and spooled to a temporary file. mhmail then invokes post with the name of the tempo-
rary file as its argument to deliver the message to the specified user.
The -subject subject switch can be used to specify the "Subject:" field of the message.
By default, mhmail will read the message to be sent from the standard input. You can specify the text of the message at the command line
with the -body text switch. If the standard input has zero length, mhmail will not send the message. You can use the switch -body "" to
force an empty message.
Normally, addresses appearing as arguments are put in the "To:" field. If the -cc switch is used, all addresses following it are placed in
the "cc:" field.
By using -from addr, you can specify the "From:" header of the draft. Naturally, post will fill-in the "Sender:" header correctly.
FILES
/usr/bin/mh/inc Program to incorporate maildrop into folder
/usr/lib/mh/post Program to deliver a message
/tmp/mhmail* Temporary copy of message
SEE ALSO
inc(1), post(8)
DEFAULTS
None
CONTEXT
If inc is invoked, then inc's context changes occur.
MH.6.8 11 June 2012 MHMAIL(1)