Sponsored Content
Top Forums Shell Programming and Scripting Help in outputting the result in log files Post 302137789 by radoulov on Thursday 27th of September 2007 03:47:21 AM
Old 09-27-2007
Code:
awk '{rec=$0;gsub(/"/,"",$1);print rec>("ss"$1".sh")}' FS="," filename

1. rec=$0 - save the current record, before modifying it with gsub (global substitution).

2. gsub(/"/,"",$1) - modify the first field ($1), remove the quotes: "40" becomes 40 and so on.

3. Print the previously saved record in a file named ss $1(from the modified current record, 40, not "40") .sh (you have to quote the literal strings - "ss" and ".sh".

4. FS is Field Separator(,).
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
YAZ_RECORD(3)								 1							     YAZ_RECORD(3)

yaz_record - Returns a record

SYNOPSIS
string yaz_record (resource $id, int $pos, string $type) DESCRIPTION
The yaz_record(3) function inspects a record in the current result set at the position specified by parameter $pos. PARAMETERS
o $id - The connection resource returned by yaz_connect(3). o $pos - The record position. Records positions in a result set are numbered 1, 2, ... $hits where $hits is the count returned by yaz_hits(3). o $type - The $type specifies the form of the returned record. Note It is the application which is responsible for actually ensuring that the records are returned from the Z39.50/SRW server in the proper format. The type given only specifies a conversion to take place on the client side (in PHP/YAZ). Besides conversion of the transfer record to a string/array, PHP/YAZ it is also possible to perform a character set conversion of the record. Especially for USMARC/MARC21 that is recommended since these are typically returned in the character set MARC-8 that is not supported by browsers, etc. To specify a conversion, add ; charset= from , to where from is the original character set of the record and to is the resulting character set (as seen by PHP). o string - The record is returned as a string for simple display. In this mode, all MARC records are converted to a line-by- line format since ISO2709 is hardly readable. XML records and SUTRS are returned in their original format. GRS-1 are returned in a (ugly) line-by-line format. This format is suitable if records are to be displayed in a quick way - for debugging - or because it is not feasible to perform proper display. o xml - The record is returned as an XML string if possible. In this mode, all MARC records are converted to MARCXML. XML records and SUTRS are returned in their original format. GRS-1 is not supported. This format is similar to $string except that MARC records are converted to MARCXML This format is suitable if records are processed by an XML parser or XSLT pro- cessor afterwards. o raw - The record is returned as a string in its original form. This type is suitable for MARC, XML and SUTRS. It does not work for GRS-1. MARC records are returned as a ISO2709 string. XML and SUTRS are returned as strings. o syntax - The syntax of the record is returned as a string, i.e. USmarc, GRS-1, XML, etc. o database - The name of database associated with record at the position is returned as a string. o array - The record is returned as an array that reflects the GRS-1 structure. This type is suitable for MARC and GRS-1. XML, SUTRS are not supported and if the actual record is XML or SUTRS an empty string will be returned. The array returned consists of a list corresponding to each leaf/internal node of GRS-1. Each list item consists a sub list with first element path and data (if data is available). The path which is a string holds a list of each tree component (of the structured GRS-1 record) from root to leaf. Each component is a tag type, tag value pair of the form ( type , value String tags nor- mally has a corresponding tag type 3. MARC can also be returned as an array (they are converted to GRS-1 internally). RETURN VALUES
Returns the record at position $pos or an empty string if no record exists at the given position. If no database record exists at the given position an empty string is returned. EXAMPLES
Example #1 Array for GRS-1 record Consider this GRS-1 record: (4,52)Robert M. Pirsig (4,70) (4,90) (2,7)Transworld Publishers, ltd. Robert M. Pirsig. Second element at root level (4,70) has a subtree with a single element (4,90). (4,90) has yet another sub tree (2,7) with data Transworld Publishers, ltd.. If this record is present at position $p, then <?php $ar = yaz_record($id, $p, "array"); print_r($ar); ?> Array ( [0] => Array ( [0] => (4,52) [1] => Robert M. Pirsig ) [1] => Array ( [0] => (4,70) ) [2] => Array ( [0] => (4,70)(4,90) ) [3] => Array ( [0] => (4,70)(4,90)(2,7) [1] => Transworld Publishers, ltd. ) ) Example #2 Working with MARCXML The following PHP snippet returns a MARC21/USMARC record as MARCXML. The original record is returned in marc-8 (unknown to most XML parsers), so we convert it to UTF-8 (which all XML parsers must support). <?php $rec = yaz_record($id, $p, "xml; charset=marc-8,utf-8"); ?> The record $rec can be processed with the Sablotron XSLT processor as follows: <?php $xslfile = 'display.xsl'; $processor = xslt_create(); $parms = array('/_xml' => $rec); $res = xslt_process($processor, 'arg:/_xml', $xslfile, NULL, $parms); xslt_free($processor); $res = preg_replace("'</?html[^>]*>'", '', $res); echo $res; ?> For PHP 5 the XSL extension must be used instead of Sablotron XSLT. PHP Documentation Group YAZ_RECORD(3)
All times are GMT -4. The time now is 06:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy