Sponsored Content
Top Forums Shell Programming and Scripting Adding a blank line in between two O/Ps in tabular format which gets received over email Post 303002963 by Sambit Sahu on Wednesday 6th of September 2017 04:20:08 AM
Old 09-06-2017
OK.. I sorted it out by myself. Below is the script:

Code:
day_of_week=`date +%w`

if [ `expr $day_of_week` == 1 ]
then
        today=`date +'%Y%m%d'`
        yes=`date -d "3 day ago" +'%Y%m%d'`
        dfy=`date -d "4 day ago" +'%Y%m%d'`


elif [ `expr $day_of_week - 1` == 1 ]
then
        today=`date +'%Y%m%d'`
        yes=`date -d "1 day ago" +'%Y%m%d'`
        dfy=`date -d "4 day ago" +'%Y%m%d'`

else

        today=`date +'%Y%m%d'`
        yes=`date -d "1 day ago" +'%Y%m%d'`
        dfy=`date -d "2 day ago" +'%Y%m%d'`
fi

#echo $today
#echo $yes
#echo $dfy


DT=($today $yes $dfy)
SEND=0
for i in 0 1 2

do

mysql test -e "select c.CenterID,a.MIC,c.ExchangeName,a.CountryCode,a.EventDate,a.EventDayOfWeek,b.eventName from exch_calendar_event a left join exch_calendar_eventName b on a.EventID=b.ID left join exch_calendar_mic c on a.MIC=c.MIC where EventDate=DATE_FORMAT(${DT[$i]},'%Y%m%d') order by a.MIC;" | tr "\t" "~" > file.tmp

if [ -s file.tmp ]
then
  {
        SEND=1
        echo "<br><b>T-$i (${DT[$i]})"
        echo "<table border=1>"
        while read -r LINE
        do
                LINE=$(echo $LINE|sed 's/~/<\/td><td>/g')
                echo "<tr><td>$LINE</td></tr>"
        done < file.tmp
        echo "</table><br>"
    } >> mail.txt
fi

done

[[ $SEND == 1 ]] && cat header1 mail.txt footer | sendmail -t
rm -f mail.txt file.tmp

Will post here, if any further help required.

Thanks!!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

adding blank line in egrep

I followed the egrep example given in the thread "parse text or complex grep ?". It is exactly what I need...except... how do I insert a blank line after the second line? My exact command is: egrep 'patt1|patt2' filename the result is: patt1 patt2 patt1 patt2 and so on. I would... (2 Replies)
Discussion started by: antalexi
2 Replies

2. Shell Programming and Scripting

Need help in sed command (adding a blank line btw each block generated by pattern)

Hello friends, I have a C source code containing sql statements. I use the following sed command to print all the sql blocks in the source code.... sed -n "/exec sql/,/;/p" Sample.cpp The above sed command will print the sql blocks based on the pattern "exec sql" & ";"... (2 Replies)
Discussion started by: frozensmilz
2 Replies

3. Shell Programming and Scripting

SED - adding blank line after each Range Match

the following range matching works great but i wish to add a blank line after each range result set... which i've tried and researched to no avail MY INPUT DATA: CURRENT CODE I'M USING: sed -n '/*$/,/;/p' $INPUT_FILE RESULTS I'M GETTING: RESULT I looking to... (5 Replies)
Discussion started by: danmauer
5 Replies

4. Shell Programming and Scripting

Fill the empty line by adding line before blank line

FIle A "A" 2 aa 34 3 ac 5 cd "B" 3 hu 67 4 fg 5 gy output shud be A"" 2 aa 34 "A" 3 ac 34 "A" 5 cd 34 "B" 3 hu 67 "B" 4 fg 67 "B" 5 gy 67 (6 Replies)
Discussion started by: cdfd123
6 Replies

5. Shell Programming and Scripting

Adding a blank line after every 5th line

Hello... I have a file which contain certain number of records. I want to generate another file from this file which will contain 1st line as a blank line & after every 5 lines one blank line will be inserted. How to achieve this through shell scripting? Thanks... (5 Replies)
Discussion started by: 46019
5 Replies

6. Shell Programming and Scripting

sed adding a blank line

I use the following as part of a script to correct for a faulty hostname file. # get the domain name read -r thehostname < /etc/hostname dom="$(echo $thehostname | cut -d'.' -f2)" numchar=${#dom} if then echo "It appears as though the hostname is not correctly set." echo "Hostname has... (5 Replies)
Discussion started by: bugeye
5 Replies

7. Shell Programming and Scripting

Displaying output in the tabular format

Hi I want to display the following input data into the tabular format as shown in the output. Input.txt: Following jobs are in pending state for more than 10 minutes: JOB_ID JOB_SUBMIT_ID MAHAR 784308 PUNJA 109367 Following jobs are running for longer time: JOB_ID... (1 Reply)
Discussion started by: dats
1 Replies

8. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

9. Shell Programming and Scripting

Required to get out put of log in tabular format in email body

Dears Please support I have out put in text file and look like below fixed inquiries - Click on MAX suffix http://server:port/app User Details http://server:port/app Audit User Detail Action hhttp://server:port/app fixed inquiries - Click on MAX suffix http://server:port/app User Details ... (13 Replies)
Discussion started by: mirwasim
13 Replies

10. Shell Programming and Scripting

To have a mail in tabular format

Hello Guys, developing a monitoring shell script to have my queue depth count over mail . here is the sample input file to the script which has all the queue names 1 : DISPLAY QUEUE(*) WHERE (CURDEPTH GT 0) ZFC8409: Display Queue details. QUEUE(QL.GVR.ATA.CACHE.01) ... (10 Replies)
Discussion started by: wims
10 Replies
holidays(4)							   File Formats 						       holidays(4)

NAME
holidays - prime/nonprime table for the accounting system SYNOPSIS
/etc/acct/holidays DESCRIPTION
The /etc/acct/holidays file describes which hours are considered prime time and which days are holidays. Holidays and weekends are con- sidered non-prime time hours. /etc/acct/holidays is used by the accounting system. All lines beginning with an "*" are comments. The /etc/acct/holidays file consists of two sections. The first non-comment line defines the current year and the start time of prime and non-prime time hours, in the form: current_year prime_start non_prime_start The remaining non-comment lines define the holidays in the form: month/day company_holiday Of these two fields, only the month/day is actually used by the accounting system programs. The /etc/acct/holidays file must be updated each year. EXAMPLES
Example 1: Example of the /etc/acct/holidays file. The following is an example of the /etc/acct/holidays file: * Prime/Nonprime Table for the accounting system * * Curr Prime Non-Prime * Year Start Start * 1991 0830 1800 * * only the first column (month/day) is significant. * * month/day Company Holiday * 1/1 New Years Day 5/30 Memorial Day 7/4 Indep. Day 9/5 Labor Day 11/24 Thanksgiving Day 11/25 day after Thanksgiving 12/25 Christmas 12/26 day after Christmas SEE ALSO
acct(1M) SunOS 5.10 28 Mar 1991 holidays(4)
All times are GMT -4. The time now is 01:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy