Cat and Email in UNIX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cat and Email in UNIX
# 1  
Old 05-02-2014
Cat and Email in UNIX

I have couple of files

1 Req:

Scenario 1: Size zero files

File1 -> HCP_ZERO.txt

Code:
HCP_1.csv
HCP_2.csv

FILE 2--> RBI_ZERO.txt

Code:
RBI_1.csv

i need to add all files which ending with _ZERO.txt in to new file


Scenario 2: Avg file issue

File1 -> HCP_AVG.txt

Code:
HCP_1.csv

FILE 2--> RBI_AVG.txt

Code:
RBI_1.csv

i need to add all files which ending with _AVG.txt in to new file




2nd Req:

send one email to end user with below

Code:
Size issue:

HCP_1.csv
HCP_2.csv
RBI_1.csv

Avg Issue:

RBI_1.csv
RBI_1.csv

Moderator's Comments:
Mod Comment Please use CODE tags as required by the forum rules. I have tried to put in appropriate tags, but this post is so vague that I have no confidence that I guessed correctly.

Last edited by Don Cragun; 05-02-2014 at 04:03 PM.. Reason: Add CODE tags.
# 2  
Old 05-02-2014
I couldn't understand the requirement correctly
What's the point in adding all the zero byte files together. Resultant will anyways be a zero byte file.
# 3  
Old 05-02-2014
Req:

1) check files size >0
2) Check avg size match to last 3 months file , if not send one email with all the errors

What I did:

We have bunch of files need to process for HCP and RBI

1) I did written code to Captured the files which are zero and does not meet Avg size for HCP.txt and RBI.txt as below in different files

Size issue :

File1 -> HCP_ZERO.txt

HCP_1.csv
HCP_2.csv

FILE 2--> RBI_ZERO.txt

RBI_1.csv

2) Avg file issue

File1 -> HCP_AVG.txt

HCP_1.csv

FILE 2--> RBI_AVG.txt

RBI_1.csv


Need help how to send one mail with all erros as given example below

Size issue:

HCP_1.csv
HCP_2.csv
RBI_1.csv

Avg Issue:

RBI_1.csv
RBI_1.csv
# 4  
Old 05-02-2014
Post #3 in this thread is a repeat of post#1 in this thread with no new information. (And, since I have no idea if I got the CODE tags correct in the 1st post I didn't bother trying to fix them in post #3.)

Please give us some concrete example of what is going on. Show us file sizes, file content, or whatever is needed to determine how the input is to be processed. Explain how you determine which files to process for data for the last three months. Explain what data you are trying to average into RBI_AVG.txt and what constitutes an error when comparing averages. Show us details about the input you have and show us the exact output you want for that sample input.
# 5  
Old 05-02-2014
email

I have two files

FILE1.txt

A.txt
B.txt
C.txt

FILE2.txt

A.txt


I need to send one email saying

FILE.txt:

A.txt
B.txt
C.txt

FILE2.txt:

A.txt
# 6  
Old 05-02-2014
PLEASE use code tags as required by forum rules!

Not sure if you want FILE.txt or FILE1.txt to be listet. Anyhow, you could use a function:
Code:
cf () 
{ 
    for x in $@;
    do
        echo $x:;
        cat "$x";
    done;
    unset x
}

and call it like cf FILE.txt FILE2.txt
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sendmail with cat adding extra spaces in email body

when I try to read a file and send email using cat and sendmail: The email received having additional spaces.(Between the letters of words in the text) My code: export MAILTO="sa@y.com" export SUBJECT="mydomain PREPROD MONITOR AT ${DATE}" export... (5 Replies)
Discussion started by: visitsany
5 Replies

2. Shell Programming and Scripting

Cannot open txt file in UNIX using cat utility

Hi, I am not being able to open txt files with 'cat'. One thing to mention is, the filenames start with #. I guess one can have a unix filename that starts with a special/wildcard character. I have filenames starting with @ and they are opening perfectly with cat. (5 Replies)
Discussion started by: Subhasis
5 Replies

3. Shell Programming and Scripting

Problem with `cat` the compiled output of C program in unix

Hello All, I have coded a C program which looks something like below... (program name: test.c) #include<stdio.h> main() { int dist,dm,dcm; printf(" Enter the distance between 2 cities in KM : "); scanf("%d",&dist); dm=dist*1000; dcm=dist*10; printf("Distance between 2 cities in... (6 Replies)
Discussion started by: smarty86
6 Replies

4. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

5. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies

6. UNIX for Dummies Questions & Answers

regarding cat and EOF in UNIX

Hi, Can anyone explain me what this function is doing cat << EOF > HELPFILE /$1/ { print "SENT" } EOF Thanks in Advance Suggestions welcome (1 Reply)
Discussion started by: trichyselva
1 Replies

7. UNIX for Dummies Questions & Answers

unix cat gives no output

hi, i searched the forum, but found no thread relate to this; so sorry if it's duplicated. I'm using unix cat command but it gives no output. I check permission, owner and group; all of which are OK. I could do less and vi. any suggestions? thanks, (2 Replies)
Discussion started by: notvwatcher
2 Replies

8. Shell Programming and Scripting

Issue with Unix cat command

Hi Experts, I am finding the performance of cat command is very wierd, it is taking more time to merge the files into a single file. We have a situation where we would be merging more than 100 files into a single file, but with cat command it is running slow. I tried doing with paste, join... (13 Replies)
Discussion started by: RcR
13 Replies

9. UNIX for Dummies Questions & Answers

Send email where # is in the email address - Using Unix

Hi All, How do I send an email using malix where email address contains a #. I have a email address like this : #test@test.com I want to send email like malix -s "TEST" #test@test.com < SOMEFILE I tried \# but doesn't work. Please let me know how we can achieve this? I am in... (1 Reply)
Discussion started by: jingi1234
1 Replies

10. UNIX for Advanced & Expert Users

Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win)

Hi A) I am able to send eMail using mailx from a UNIX ( solaris 8 ) host to my Outlook-email-ID : FName.Surname@Citigroup.com ( This is NOT my actual -eMail-ID). But in Outlook the "From :" eMail address is displayed as " usr1@unix-host1.unregistered.email.citicorp.com " .i.e the words... (2 Replies)
Discussion started by: Vetrivela
2 Replies
Login or Register to Ask a Question