Help in outputting the result in log files


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 15  
Quote:
Originally Posted by royalibrahim
radoulov, you have missed "$0" after print, i.e print $0 > ......
[...]
Do you really think we need it Smilie
Did you try it?
# 16  
Quote:
Originally Posted by royalibrahim
[...]And also the redirection operator is in "overwrite mode", so each time it would clear the file and injects the record afresh, so how here the records are appended correctly? Please correct me, if I am wrong.
Nope! The awk redirection is different from the shell redirection Smilie
I would suggest reading Effective AWK Programming (it's free):
http://www.gnu.org/software/gawk/manual/gawk.pdf
# 17  
sorry radoulov, I don't have "nawk" in my system so I didn't try it. But it works perfectly fine in presence and absence of "$0" as you mentioned for "awk". Sorry for my wrong comment posted earlier. But can you answer me for my question regarding checking of the value like 40, 46 .. etc.,? I will definitely go through the PDF document.
# 18  
Quote:
Originally Posted by royalibrahim
[...]
But I have a doubt here, how your script checks whether 40 should go to the "ss40.sh", 46 to the "ss46.sh" and so on.
It doesn't check anything: $2 is variable (so the filename to append varies),
it changes with the record, so if the record's second field is 40,
it goes to file named "ss"$2".sh" -> "ss"40".sh".

P.S. Feel free to correct my englishSmilie HTH.

Last edited by blowtorch; 09-27-2007 at 08:10 AM.. Reason: fixed spelling for field
# 19  
Just beat me to it! Was going to give almost exactly the same answer. BTW, since you said to correct your English, I did fix a spelling mistake in your post. Hope you don't mind. Smilie
# 20  
Of course, not Smilie
Thank you, blowtorch!
# 21  
Yes, got the essence after reading the PDF "regarding redirection & print with no arguments", thanks a lot radoulov. You're awesome :-)

For the sake of clarity for the other users, I am posting the excerpt taken from the PDF that cleared my doubts (note: I just edited a bit)

The simple statement 'print' with no items is equivalent to 'print $0', it prints the entire current record. When '>' type of redirection is used in print eg: print val > file, the output file is erased before the first output is written to it. Subsequent writes to the same output file do not erase the file, but append to it. This is different from how you use redirections in shell scripts.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #71
Difficulty: Easy
Linux, macOS, Android, iOS, Chrome OS, Orbis OS used on the PlayStation 4, whatever firmware is running on your router, all of these operating systems are generally referred to as a Unix-like operating system.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Outputting data from log file to report

I have a log file that looks like this. the lines are grouped. 2 lines per entry. M: 2019-01-25 13:02:31.698 P25, received network transmission from KI4EKI to TG 10282 M: 2019-01-25 13:02:35.694 P25, network end of transmission, 4.3 seconds, 1% packet loss M: 2019-01-25 13:02:38.893 P25,... (7 Replies)
Discussion started by: ae4ml
7 Replies

2. Shell Programming and Scripting

Outputting Errors to a Log file

Good Morning, Every so often, I have copy scripts that to don't complete, but I don't immediately know why. It usually ends up being a permissions issue or a length issue. The scripts edit a log file, so I'd like to include any copy errors/issues in that file to check if the copies... (4 Replies)
Discussion started by: Stellaman1977
4 Replies

3. UNIX for Beginners Questions & Answers

Comparing fastq files and outputting common records

I have two files: File_1: @M04961:22:000000000-B5VGJ:1:1101:9280:7106 1:N:0:86 GGCATGAAAACATACAAACCGTCTTTCCAGAAATTGTTCCAAGTATCGGCAACAGCTTTATCAATACCATGAAAAATATCAACCACACCAGAAGCAGCAT + GGGGGGGGGGGGGGGGGCCGGGGGF,EDFFGEDFG,@DGGCGGEGGG7DCGGGF68CGFFFGGGG@CGDGFFDFEFEFF:30CGAFFDFEFF8CAF;;8F ... (3 Replies)
Discussion started by: Xterra
3 Replies

4. UNIX for Dummies Questions & Answers

Outputting 1 file per row if pattern exists between files

I have many files that can have various amounts of rows. I essentially want to output each row into a new file if a pattern is matched between two files. I have some code that does something similar but I want it to output every single input row from every file into a separate output file; that... (5 Replies)
Discussion started by: verse123
5 Replies

5. Shell Programming and Scripting

Copying files after result

Hi, I have a shell script #!/bin/sh date echo 'HI PROD' echo $Please ENTER THE INPUT 1 for old files 2 for new file read i if ; then cd /apps/acetp3_logs/prod3/O* pwd echo $PLEASE ENTER THE STRING TO SEARCH (PLEASE ENTER THE STRING INSIDE QUOTES ' ') read j echo... (6 Replies)
Discussion started by: thelakbe
6 Replies

6. UNIX for Dummies Questions & Answers

rm command-outputting files as they are deleted?

Solaris 10/Korn Hi unix experts!, Is it possible to output the actual file names to a file as they are being deleted via the rm command? Context: Im executing the shell script at the command line and directing the output to an output file eg purgescript.ksh > output.lst within the... (3 Replies)
Discussion started by: satnamx
3 Replies

7. Shell Programming and Scripting

write a perl script or kornshell reading a two files and outputting to comma format

Hello Can someone help me to write a perl script or kornshell reading a two files and outputting to comma format. Here is the two files listofdisks.txt id, diskname, diskgroup, diskisze(GB), FC 1, CN34, GRP1, 30, FC_CN34 2, CN67, GRP5, 19, 4, VD1, GRP4, 23, FC_VD1 6, CF_D1, ... (0 Replies)
Discussion started by: deiow
0 Replies

8. Shell Programming and Scripting

Read multiple log files and create output file and put the result

OS : Linux 2.6.9-67 - Red Hat Enterprise Linux ES release 4 Looking for a script that reads the following log files that gets generated everynight between 2 - 5am Master_App_20090717.log Master_App1_20090717.log Master_App2_20090717.log Master_App3_20090717.log... (2 Replies)
Discussion started by: aavam
2 Replies

9. Shell Programming and Scripting

Outputting formatted Result log file from old 30000 lines result log<help required>

Well I have a 3000 lines result log file that contains all the machine data when it does the testing... It has 3 different section that i am intrsted in 1) starting with "20071126 11:11:11 Machine Header 1" 1000 lines... "End machine header 1" 2) starting with "20071126 12:12:12 Machine... (5 Replies)
Discussion started by: vikas.iet
5 Replies

10. Shell Programming and Scripting

Outputting from two input files.

Ok, lets suppose I have two files like so: file1 John 5441223 Sandy 113446 Jill 489799 file2 Sandy Tuesday Jill Friday John Monday Is it possible to match records from these two files and output them into one output file? For example, lets suppose I want to output like this: ... (5 Replies)
Discussion started by: Liguidsoul
5 Replies

Featured Tech Videos