I was wondering what command lines i could use to do the following.
-
mail a file to a user with a subject line "HELLO". Also, send a Blind carbon copy to a different user?
-
Display the number of files AND directories in a given directory?
-
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!
Have you missed these pages?
1. man mail
2. man ls, man wc
3. man tail
Regards
1.) mailx -s Hello to.person1@mail.com to.person2@mail.com < /path/file
Regards
wouldn't that just mail the file to both users?
I need to mail the file to one user, and in the same line send a blind carbon copy to a different user.
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)