Sponsored Content
Top Forums Shell Programming and Scripting adding another field to SED output Post 302368565 by aismann on Thursday 5th of November 2009 04:55:13 AM
Old 11-05-2009
adding another field to SED output

Dear experts,

I have a file called "check" with contents like below

Quote:
KPG-HF4-3
04/11/2009 03:15 InsertSubData
success failed
17752 6
6 Timeout
i used the sed command like below to get the value of "success" and "failed" only

Quote:
sed -n -e '/KPG-HF4-3/{ p; n; p; n; p; n; p; n;}' check | tail -1 | awk {'print $1,$2'}

17752 6
My question is how can i get the value to include the time "03:15", so that i can get a value such as below : -

Quote:
03:15 17752 6
Appreciate any advice. Thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Adding a new field using sed or awk?

I have a bcp file that contains 10 fields. These fields are separated by a tab. How can I add my name as a new field in the 8th position for every record? I've been playing w/ sed and awk but can't seem to figure this out. (3 Replies)
Discussion started by: sasabune
3 Replies

2. Shell Programming and Scripting

adding field values if field matches

hi i have file as below , i want to add duplicate records like bell_bb to one record with valuve as 15 ( addition of both ) any oneline awk script to achive this ? header 0 CAMPAIGN_NAME 1 Bell_BB 14 Bell_MONTHLY 803 SOLO_UNBEATABLE 644 Bell_BB 1 Bell_MONTHLY 25 SOLO_UNBEATABLE... (4 Replies)
Discussion started by: raghavendra.cse
4 Replies

3. Shell Programming and Scripting

Adding new field

Hello, I have a main file with IP addresses like this: Erisim var,100,172.17.241.5,4006,60,IS0799,TCP/IP Erisim var,1003,172.17.140.4,4004,60,IS2156,TCP/IP Erisim var,1004,172.17.140.5,4002,60,IS2636,TCP/IP Erisim var,1005,172.17.140.5,4004,60,IS2436,TCP/IP Erisim... (8 Replies)
Discussion started by: Spunkerspawn
8 Replies

4. Shell Programming and Scripting

Adding total of first field for each number in the second field

Dears, I need a script or command which can find the unique number from the second filed and against that number it adds the total of first field . 17215630 , 0 907043 ,1 201050 ,10 394149 ,4 1964 ,9 17215630, 0 907043 ,1 201050, 10 394149 ,4 1964 ,9 1234234, 55 23 ,100 33 ,67 ... (2 Replies)
Discussion started by: shary
2 Replies

5. Shell Programming and Scripting

Adding matching field

I have a flat file test.log red,5,,,,, green,7,,,,, blue,4,,,,, red,8,,,,, green,9,,,,, How i get a a result: blue,4,,,,, green,16,,,,, red,13,,,,, Thanks Video tutorial on how to use code tags in The UNIX and Linux Forums. (2 Replies)
Discussion started by: sabercats
2 Replies

6. Shell Programming and Scripting

Compare two files Field by field and output the result in another file

Hi Friends, Need Help. I have file1.txt as File1.txt |123|A|7267|Hyder|Cross|Sell|7801 |995|A|7051|2008|Lunar|New|Year|Promotion|7801 |996|A|7022|Q108|Targ|Prospect|&|SSCC|Savings|Promo|7801 |997|A|7182|Q1|Feb-Apr|08|Credit|ITA|PA|SBA|Campaign|7801 File2.txt... (7 Replies)
Discussion started by: i150371485
7 Replies

7. Shell Programming and Scripting

Plz Help. Compare 2 files field by field and get the output in another file.

Hi Freinds, I have 2 files . one is source.txt and second one is target.txt. I want to keep source.txt as baseline and compare target.txt. please find the data in 2 files and Expected output. Source.txt 1|HYD|NAG|TRA|34.5|1234 2|CHE|ESW|DES|36.5|134 3|BAN|MEH|TRA|33.5|234... (5 Replies)
Discussion started by: i150371485
5 Replies

8. Shell Programming and Scripting

sed : Second field not getting displayed in the output

Hi , I have a file (input.txt) with the below contents : 20150223T12:00:25 hostnamex 20150716T10:40:54 hostnamey 20150202T20:08:03 hostnamez I want the output to be like below i.e excluding the timestamp ( THH:MM:SS) in the above file as follows : 20150223 hostnamex 20150716... (2 Replies)
Discussion started by: rahul2662
2 Replies

9. Shell Programming and Scripting

Adding field to file

Hi I have file as given below 040|14300|40.0|563000 042|13200000|40.0 041|100|40.0 043|10000|40.0 045|102|40.0 I want to check if field 4 is null then I have to place | in position 4. result set should be 040|14300|40.0|563000 042|13200000|40.0| 041|100|40.0| 043|10000|40.0|... (9 Replies)
Discussion started by: shabeena
9 Replies

10. UNIX for Dummies Questions & Answers

Combine Similar Output from the 2nd field w.r.t 1st Field

Hi, For example: I have: HostA,XYZ HostB,XYZ HostC,ABC I would like the output to be: HostA,HostB: XYZ HostC:ABC How can I achieve this? So far what I though of is: (1 Reply)
Discussion started by: alvinoo
1 Replies
MAXDB_FETCH_FIELDS(3)							 1						     MAXDB_FETCH_FIELDS(3)

maxdb_fetch_fields - Returns an array of resources representing the fields in a result set

       Procedural style

SYNOPSIS
mixed maxdb_fetch_fields (resource $result) DESCRIPTION
Object oriented style mixed maxdb_result::fetch_fields (void ) This function serves an identical purpose to the maxdb_fetch_field(3) function with the single difference that, instead of returning one resource at a time for each field, the columns are returned as an array of resources. RETURN VALUES
Returns an array of resources which contains field definition information or FALSE if no field information is available. Object properties +-----------+---------------------------------------------------+ | Property | | | | | | | Description | | | | +-----------+---------------------------------------------------+ | name | | | | | | | The name of the column | | | | |max_length | | | | | | | The maximum width of the field for the result | | | set. | | | | | type | | | | | | | The data type used for this field | | | | | decimals | | | | | | | The number of decimals used (for integer fields) | | | | +-----------+---------------------------------------------------+ EXAMPLES
Example #1 Object oriented style <?php $maxdb = new maxdb("localhost", "MONA", "RED", "DEMODB"); /* check connection */ if (maxdb_connect_errno()) { printf("Connect failed: %s ", maxdb_connect_error()); exit(); } $query = "SELECT name, cno from hotel.customer ORDER BY cno"; if ($result = $maxdb->query($query)) { /* Get field information for all columns */ $finfo = $result->fetch_fields(); foreach ($finfo as $val) { printf("Name: %s ", $val->name); printf("Table: %s ", $val->table); printf("max. Len: %d ", $val->max_length); printf("Flags: %d ", $val->flags); printf("Type: %d ", $val->type); } $result->close(); } /* close connection */ $maxdb->close(); ?> Example #2 Procedural style <?php $link = maxdb_connect("localhost", "MONA", "RED", "DEMODB"); /* check connection */ if (maxdb_connect_errno()) { printf("Connect failed: %s ", maxdb_connect_error()); exit(); } $query = "SELECT name, cno from hotel.customer ORDER BY cno"; if ($result = maxdb_query($link, $query)) { /* Get field information for all columns */ $finfo = maxdb_fetch_fields($result); foreach ($finfo as $val) { printf("Name: %s ", $val->name); printf("Table: %s ", $val->table); printf("max. Len: %d ", $val->max_length); printf("Flags: %d ", $val->flags); printf("Type: %d ", $val->type); } maxdb_free_result($result); } /* close connection */ maxdb_close($link); ?> The above example will output something similar to: Name: NAME Table: max. Len: 10 Flags: -1 Type: 2 Name: CNO Table: max. Len: 4 Flags: -1 Type: 0 SEE ALSO
maxdb_num_fields(3), maxdb_fetch_field(3), maxdb_fetch_field_direct(3). PHP Documentation Group MAXDB_FETCH_FIELDS(3)
All times are GMT -4. The time now is 05:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy