Sponsored Content
Top Forums Shell Programming and Scripting need to insert two columns (or two feilds) at the begining of the table Post 302250089 by zeekblack on Wednesday 22nd of October 2008 05:11:31 PM
Old 10-22-2008
Question need to insert two columns (or two feilds) at the begining of the table

Hey guys/gals,

So here is what i'm starting with...its a Solaris patch diag output.

bash-3.0# pca -l
Using /var/tmp/patchdiag.xref from Oct/20/08
Host: seiftsx4140 (SunOS 5.10/Generic_127128-11/i386/i86pc)
List: missing

Patch IR CR RSB Age Synopsis
------ -- - -- --- --- -------------------------------------------------------
119255 53 < 59 RS- 21 SunOS 5.10_x86: Install and Patch Utilities Patch
118668 15 < 17 -S- 106 JavaSE 5.0_x86: update 16 patch (equivalent to JDK 5.0u16)
118736 01 < 02 --- 153 SunOS 5.10_x86: usr/sbin/rpc.nisd_resolv Patch
118825 01 < 02 --- 152 SunOS 5.10_x86: sort patch
119043 10 < 11 R-- 140 SunOS 5.10_x86: svccfg & svcprop patch
119060 39 < 44 RS- 82 X11 6.6.2_x86: Xsun patch
119091 26 < 32 R-- 42 SunOS 5.10_x86: Sun iSCSI Device Driver and Utilities
119214 16 < 17 -S- 231 NSS_NSPR_JSS 3.11.9_x86: NSPR 4.7 / NSS 3.11.9 / JSS 4.2.6
119247 32 < 34 R-- 61 SunOS 5.10_x86: Manual Page updates for Solaris 10
119253 25 < 29 R-- 22 SunOS 5.10_x86: System Administration Applications Patch
119281 17 < 18 --- 141 CDE 1.6_x86: Runtime library patch for Solaris 10
119398 06 < 07 --- 107 SunOS 10_x86: Patch for North America Region locale issues
--------------------------------------
I then run this...
Code:
pca -l | awk '{print $1";"$2";"$4";"$5";"$6";"$7,$8,$9,$10,$12,$15,$16,$18,$19,$20,$21,$22}' |sed -e '1,6 d'

--------------------------------------
and I get this in return....

119255;53;59;RS-;21;SunOS 5.10_x86: Install and Utilities
118668;15;17;-S-;106;JavaSE 5.0_x86: update 16 (equivalent 5.0u16)
118736;01;02;---;153;SunOS 5.10_x86: usr/sbin/rpc.nisd_resolv Patch
118825;01;02;---;152;SunOS 5.10_x86: sort patch
119043;10;11;R--;140;SunOS 5.10_x86: svccfg & patch
119060;39;44;RS-;82;X11 6.6.2_x86: Xsun patch
119091;26;32;R--;42;SunOS 5.10_x86: Sun iSCSI Driver
119214;16;17;-S-;231;NSS_NSPR_JSS 3.11.9_x86: NSPR 4.7 NSS JSS 4.2.6
119247;32;34;R--;61;SunOS 5.10_x86: Manual Page for
119253;25;29;R--;22;SunOS 5.10_x86: System Administration Patch
119281;17;18;---;141;CDE 1.6_x86: Runtime library for
119398;06;07;---;107;SunOS 10_x86: Patch for America issues
-----------------------------------------
what I'm doing is dumping this into a mysqlDB, however I think i need to add date and hostname fields to link table in my php frontend. So, Is there a way to make the output look like this...

$hostname;$date;119255;53;59;RS-;21;SunOS 5.10_x86: Install and Utilities
$hostname;$date;118668;15;17;-S-;106;JavaSE 5.0_x86: update 16 (equivalent 5.0u16)
$hostname;$date;118736;01;02;---;153;SunOS 5.10_x86: usr/sbin/rpc.nisd_resolv Patch
 

10 More Discussions You Might Find Interesting

1. Programming

Insert Text at begining of file

Hi All, Its been a long time since i did any programming and I am trying to get back into it as part of also learning Linux. Coming from a Cpp background i am trying to write some simple code just using C. I want to create a simple log file but instead of appending to the end of the file i... (3 Replies)
Discussion started by: netwolf
3 Replies

2. Shell Programming and Scripting

search a pattern and if pattern found insert new pattern at the begining

I am trying to do some thing like this .. In a file , if pattern found insert new pattern at the begining of the line containing the pattern. example: in a file I have this. gtrow0unit1/gctunit_crrownorth_stage5_outnet_feedthru_pin if i find feedthru_pin want to insert !! at the... (7 Replies)
Discussion started by: pitagi
7 Replies

3. Shell Programming and Scripting

Insert value to ORACLE table from sqlldr log

This is the sample sqlldr log: ------------------------------------------------------------------------------------------------------------ SQL*Loader: Release 9.2.0.7.0 - Production on Sun Feb 8 23:37:02 2009 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Control... (13 Replies)
Discussion started by: aimy
13 Replies

4. Shell Programming and Scripting

select values from db1 table and insert into table of DB2

Hi I am having three oracle databases running in three different machine. their ip address is different. from one of the DB am able to access both the databases.(means am able to select values and insert values in to tables individually.) I need to fetch some data from DB1 table(say DB1 ip is... (2 Replies)
Discussion started by: aemunathan
2 Replies

5. Shell Programming and Scripting

Insert into Oracle table thru UNIX - linux 2.6.9-89

Hi, I am trying to insert a record into a table (say dips_tbl) which resides in Oracle DB through a ksh script. I want to insert records into few of the table columns-not all. I'll give an e.g. for the date column "CREATE_DATE". For that I first execute SQL1="SELECT SYSDATE FROM DUAL" ... (1 Reply)
Discussion started by: dips_ag
1 Replies

6. Shell Programming and Scripting

Insert script result into Oracle Table

Hi All, I want to insert STAT and ENDTIME values for each job in joblist into TBL_DAILY_STATUS table. Eg: insert into tbl_daily_status values(STAT,ENDTIME); Please help me on this. #!/bin/ksh joblist="com_abc_job com_abc_dot_job com_abc_seq com_abc_det" for i in $joblist do... (8 Replies)
Discussion started by: vichuelaa
8 Replies

7. Programming

Table Locking in Insert Command.

Hi, i have a java based tool which does insert operation in a TABLE, and in parallel the same table is used by my C++ code which does select Query. the Table will be always busy, but sometimes the table is getting locked when i try to make an insert, am bit confused whether the lock is... (0 Replies)
Discussion started by: senkerth
0 Replies

8. Shell Programming and Scripting

Insert bulk values in DB table using isql

Hello, Objective is to insert bulk values in DB table using isql. Following code tried: isql -SServer_name -Ddb_name -Uuser_name -Ppassword < file.txt cat file.txt for i in `cat data_value_file.txt` do insert into tempdb..temp_table11 values ('$i') go done cat... (3 Replies)
Discussion started by: manishdivs
3 Replies

9. Shell Programming and Scripting

Insert one table and update another with shellscript

I have a problem with my shell script. I want to insert data from file to table1(empty) and then, compare table1 with table2 and update some fields. The first part is correct, but the second part does not work. The only way it works is if after the first part I truncate table1 and run the script... (1 Reply)
Discussion started by: nika_mill
1 Replies

10. UNIX for Beginners Questions & Answers

1. This will insert the records into db table by reading from ta csv file

I have this code with me but the condition is If any of the mandatory columns are null then entire file will be rejected. LOAD DATA infile ' ' #specifies the name of a datafile containing data that you want to load BADFILE ' ' #specifies the name of... (1 Reply)
Discussion started by: raka123
1 Replies
SHTOOL-TABLE.TMP(1)					      GNU Portable Shell Tool					       SHTOOL-TABLE.TMP(1)

NAME
shtool-table - GNU shtool pretty-print a field-separated list SYNOPSIS
shtool table [-F|--field-sep sep] [-w|--width width] [-c|--columns cols] [-s|--strip strip] strsepstr... DESCRIPTION
This pretty-prints a list of strings as a table. OPTIONS
The following command line options are available. -F, --field-sep sep Separate columns using sep. Default is ":". -w, --width width Width of each column. Default is 15 characters. -c, --columns cols Number of columns. Default is 3. -s, --strip strip Strip off any characters past strip. Default is 79. EXAMPLE
# shell script shtool table -F , -w 5 -c 4 "1,2,3,4,5,6,7,8,9,10,11,12" HISTORY
The GNU shtool table command was originally written by Ralf S. Engelschall <rse@engelschall.com> in 1999 for GNU shtool. SEE ALSO
shtool(1), tr(1), fmt(1), sh(1), awk(1), sed(1). 18-Jul-2008 shtool 2.0.8 SHTOOL-TABLE.TMP(1)
All times are GMT -4. The time now is 07:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy