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
getcol(1)						      General Commands Manual							 getcol(1)

Name
       getcol - Extract specified columns from an ASCII table file

Synopsis
       getcol [-amv][-n num][-r lines][-s num] filename [column number range]

Description
       Extract specified columns from an ASCII table file

Options
       filename
	      Name  of a ASCII table file.  At least one of these must be present for any values to be printed.  If it is stdin or STDIN, an ASCII
	      table is expected as standard input.  If there is no input file, standard input is assumed.

       @filename
	      Name of a file containing a list of ASCII table files.  If this is present, any other  file  names  on  the  command  line  will	be
	      ignored.

       field range
	      Print  value  of	these  columns for the number of lines of the table specified by the -n argument after the skippiing the number of
	      lines specified by the -s argument.  A value of 0 causes the entire input line to be printed.

       -a     Sum all numeric columns selected, printing the sum on the line following the result.  Columns with  no  sum  are	filled	with  ___.
	      (Added in version 2.6.9)

       -b     Input is bar-separate table file

       -c     Add count of number of lines in each column at end

       -d <number>
	      Number of decimal places in f.p. output

       -e     Compute medians of selected columns

       -f     Print range of values in selected columns

       -h     Print Starbase tab table header

       -i     Input is tab-separate table file

       -k     Print number of columns on first line

       -l <number>
	      Number of lines to add to each line

       -m     Compute the means of all numeric columns selected, printing the mean on the line following the result (or the line following the sum
	      if -a is used).  Columns with no mean are filled with ___.  (Added in version 2.6.9)

       -n num Print selected columns for this many lines.  If not specified, all lines will be read after the number of lines specified by -s have
	      been skipped.

       -o     OR conditions insted of ANDing them

       -p     Print only sum, mmean, sigma, median, or range, not entries

       -r @listfile
	      -r  line	range  Print  columns from the lines specified as either the first nonzero number on each line of the file listfile or the
	      comma- and hyphen- delimitied range; i.e. 1-5,10-12 will print values from lines 1, 2, 3, 4, 5, 10, 11, and 12.  (added  in  version
	      2.6.12)

       -s num Skip this many line before starting to print values.  If not specified, no lines will be skipped.

       -t     Starbase (tab-separated) table output

       -v     Print more information about process.

       Web Page
	      http://tdc-www.harvard.edu/software/wcstools/getcol.html

Author
       Doug Mink, SAO (dmink@cfa.harvard.edu)

8 November 2001 						     WCSTools								 getcol(1)
All times are GMT -4. The time now is 04:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy