LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-13-2004, 05:59 PM   #1
Warmduvet
Member
 
Registered: Jun 2004
Location: New Zealand
Posts: 60

Rep: Reputation: 15
shell script to copy lines from a file


Hi I want to create a script that will copy the daily mail from /var/spool/mail/root and send it to a user.

as in copy from var/spool/mail/root where date = date > /home/user/tmp

any pointers appreciated

WD
 
Old 09-13-2004, 08:25 PM   #2
scottman
Member
 
Registered: Jul 2004
Location: USA
Distribution: Slackware, FreeBSD, LFS
Posts: 72

Rep: Reputation: 15
Code:
#!/bin/bash
 
day=$(date +%d)
let yesterday=$day-1
month=$(date "+%b")
grepline="$month $yesterday"

grep -m 2 --after-context=100 "${grepline}" /var/spool/mail/root
It seems to work ok for me pulling out yesterdays mail. Maybe send
the output to a file or something.
 
Old 09-14-2004, 09:25 PM   #3
Warmduvet
Member
 
Registered: Jun 2004
Location: New Zealand
Posts: 60

Original Poster
Rep: Reputation: 15
Thanks for that I will have a play with it.

WD
 
  


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
Inserting lines into a file through shell scripting false-hopes Linux - General 1 10-22-2005 11:39 AM
Shell script to copy file name with part of directory Transition Linux - General 5 01-18-2005 05:40 PM
Shell Script (adding a prefix to output lines) rheza Programming 3 01-04-2005 01:18 PM
[c shell] How do I find how many lines a file has? saiz66 Programming 5 10-08-2004 03:01 PM
Can't get lines of a file with a Bash script.. barisdemiray Programming 2 08-11-2004 12:42 PM


All times are GMT -5. The time now is 08:38 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration