Date included

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Date included
# 1  
Old 01-26-2017
Date included

Code:
#!/usr/bin/ksh

# This script reads the *.rpt files created by xenos during job execution.
# The job name, jobid, number of pages processed and pdf files created for each job
# are added to the xenoshistory.txt file


[for file in $(find /d2e/logs/*.rpt -mtime -2 | grep -v ftplog)
 do
   awk '$3 == "Application" {QName = $6}
        $2 == "XifPages" {pages = $6}
        $2 == "XifEndOfDocuments" {files = $6}
        index($0,"CompletionCode") && index($1,"Info"){sevGTI = 1}
           END {if (sevGTI)
                printf "%10s%10s%7s%s",QName,pages,files,ORS
             }
       ' $file>>/home/p611568/new.txt
       chmod 775 /home/p611568/new.txt
echo $'   QName\tPages\tFiles'  | cat - new.txt > count.txt

done]

Currently the ouput file looks like this but I need a date where the xxxx is
Code:
$ cat new.txt
XXXXX
      QName       Pages   Files
      efvahi1       102     85
      efvahi1       102     85


Last edited by RudiC; 01-27-2017 at 04:29 AM..
# 2  
Old 01-26-2017
Code tags for code, please.

The extra brackets in your code would prevent it from working.
# 3  
Old 01-26-2017
Quote:
Originally Posted by Corona688
Code tags for code, please.

The extra brackets in your code would prevent it from working.
yes I thought that was what you meant for the code. I placed brackets around it. I don't understand what you mean by code tags That is why I used the brackets for code tags. do you know what I could do to get it to work with a date without the brackets as I have it working I just need a date where the xxx is?

---------- Post updated at 05:46 PM ---------- Previous update was at 05:37 PM ----------

Code:
#!/usr/bin/ksh

# This script reads the *.rpt files created by xenos during job execution.
# The job name, jobid, number of pages processed and pdf files created for each job
# are added to the xenoshistory.txt file


for file in $(find /d2e/logs/*.rpt -mtime -2 | grep -v ftplog)
do
awk '$3 == "Application" {QName = $6}
$2 == "XifPages" {pages = $6}
$2 == "XifEndOfDocuments" {files = $6}
index($0,"CompletionCode") && index($1,"Info"){sevGTI = 1}
END {if (sevGTI)
printf "%10s%10s%7s%s",QName,pages,files,ORS
}
' $file>>/home/p611568/new.txt
chmod 775 /home/p611568/new.txt
echo $' QName\tPages\tFiles' | cat - new.txt > count.txt

done


Currently the ouput file looks like this but I need a date where the xxxx is
Code:
$ cat new.txt
XXXXX
QName Pages Files
efvahi1 102 85
efvahi1 102 85

Moderator's Comments:
Mod Comment Using CODE tags is not that difficult and you have been given the following directions on how to use them before:
Quote:
To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)



Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
Please click on the tutorial above, or edit this message so you can see how CODE and ICODE tags can be used properly (CODE tags for full-line and multi-line sample input, sample output, and code segments; ICODE tags for partial line sample input, sample output, and code segments).

Last edited by Don Cragun; 01-26-2017 at 11:37 PM..
# 4  
Old 01-27-2017
I'm confused. You say that your output looks like your input file. And since nothing in your code makes any modifications to that input file (it adds some text at the start of the output file and copies that text to the end of the output), why don't you just change the XXXXX in the 1st line of the file named new.txt to be the date string that you want to copy into your output file? Are you saying that the for loop before the cat in the pipeline in your script does not find any files to add any data to your output?

And, exactly what date string format did you want to use instead of the XXXXX that is current in new.txt and, unless the date string you want is the current date and time when your script is run, where is that date string supposed to be found?
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rm -rf file.txt~ included in the first step?

I need to shred and delete a file after a certain time. Therefore I use shred -z /path/to/file.txt | rm -rf /path/to/file.txtIt works well, but typing in that very directory ls -shiI still see the so called backup-copy lets say file.txt~ When running bleachbit it will disappear thoroughly.... (3 Replies)
Discussion started by: 1in10
3 Replies

2. UNIX for Dummies Questions & Answers

Create a condition for a non-included string

hey, just want to ask how to check this scenario a="apple banana cherry" if egg=0 fi how do you do the condition? thanks! (2 Replies)
Discussion started by: h0ujun
2 Replies

3. Programming

Compile error from included headers

Hello, I have an error when I include the socket.h linux header and compile with gcc. In file included from /usr/include/sys/socket.h:40:0, from test.c:17: /usr/include/bits/socket.h:217:5: error: expected identifier before numeric constant In test.c:17: #include... (4 Replies)
Discussion started by: meltingshell
4 Replies

4. Solaris

What update level included fcinfo?

Hi all first post here. quick question what Solaris 10 update level included this utility? I have a bunch of Sun boxes at varying levels of Solaris 10 some have it some do not. When I do my install I take the full option for the packages to install on all the systems. thanks in advance... Mike (4 Replies)
Discussion started by: mike_243us
4 Replies

5. UNIX for Dummies Questions & Answers

Addition with the prefixing zeros included

Hi I need to do an add function but it should include the prefixed zeros For Example i=00123 j=`expr $i + 1` The output it shows is 124 but I want the output to be 00124 Could any one help me finding out how to do this Thanks (16 Replies)
Discussion started by: sivasenthil_k
16 Replies

6. Shell Programming and Scripting

PS1 with date stamp included in prompt

How would I put the date within my PS1 command for my shell prompt? I have it set to: PS1='$>' I tried PS1='$>' but that didn't work. (7 Replies)
Discussion started by: kymberm
7 Replies
Login or Register to Ask a Question