Second Column Read


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Second Column Read
# 1  
Old 10-13-2009
Second Column Read

I'm trying to run a sql query

Code:
VAR=`isql -S SERVER -U user -P password <<EOF
select col1 , col2 from table
go
EOF`

How do i get only the first column of the results ?
# 2  
Old 10-13-2009
Code:
select col1 from table ...

# 3  
Old 10-13-2009
Naah I need both columns to be included in the select since i would be using the other column as well.
# 4  
Old 10-13-2009
Could you post an example of the VAR value?
It should be easier if you try to explain what exactly you're trying to achieve by accessing only the first column.
# 5  
Old 10-13-2009
var would contain something like

1 ABC 2 DEF 3 IOP

But when i write it to a file it gets format like below -

1 ABC
2 DEF
3 IOP

What I need is firstly the id then i require the second column values for further processing.
# 6  
Old 10-13-2009
May be something like this,
Code:
cut -d ' ' -f 1

# 7  
Old 10-13-2009
may be:

Code:
echo -e $VAR | cut -d ' ' -f 1


Last edited by inotech; 10-13-2009 at 11:41 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read first column and count lines in second column using awk

Hello all, I would like to ask your help here: I've a huge file that has 2 columns. A part of it is: sorted.txt: kss23 rml.67lkj kss23 zhh.6gf kss23 nhd.09.fdd kss23 hp.767.88.89 fl67 nmdsfs.56.df.67 fl67 kk.fgf.98.56.n fl67 bgdgdfg.hjj.879.d fl66 kl..hfh.76.ghg fl66... (5 Replies)
Discussion started by: Padavan
5 Replies

2. Shell Programming and Scripting

Read column and find differences...

I have this file 427 A C A/C 12 436 G C G/C 12 445 C T C/T 12 447 A G A/G 9 451 T C T/C 5 456 A G A/G 12 493 G A G/A 12 I wanted to read the first column and find all other ids which are differences less than 10. 427 A C A/C 12 436 436 G C G/C 12 427,445... (7 Replies)
Discussion started by: empyrean
7 Replies

3. Programming

Read column into hash

Hi, I want to read the __DATA__ into hashes with the first word (indented) of each part as key and the rest of the part (an array as value). Each part of the input is identified by the indentation. i.e. "The Skipper", "Professor", "Gilligan" are three identifiers as they do not have indentation,... (7 Replies)
Discussion started by: yifangt
7 Replies

4. Shell Programming and Scripting

how to read a certain column from the status result

I am using this script to get the status of the running process VAR=$(ps -ef | grep batch_proc_x | grep -v grep) echo $VAR now it returns this splgwin 13195 13100 0 14:13:13 pts/tb 0:00 /usr/bin/ksh ./batch_proc_x.sh now is there a way to read that time 14:13:13 directly from... (2 Replies)
Discussion started by: akabir77
2 Replies

5. Shell Programming and Scripting

How to read different lines into column

Dear experts, Need your great help ! The input file is as follows: Name: test01 Name UID: C7:9D:79:52:2A:3F:DF:11:A8:64:00:60:16:36:04:02 Shareable: YES HBA/SP Pairs: HBA UID SP Name SPPort ------- ... (9 Replies)
Discussion started by: tojzz
9 Replies

6. Shell Programming and Scripting

Read CSV column value based on column name

Hi All, I am newbie to Unix I ve got assignment to work in unix can you please help me in this regard There is a sample CSV file "Username", "Password" "John1", "Scot1" "John2", "Scot2" "John3", "Scot3" "John4", "Scot4" If i give the column name as Password and row number as 4 the... (3 Replies)
Discussion started by: JohnGG
3 Replies

7. Shell Programming and Scripting

read column values one after another

hi, Can some one help me how to retrieve column values row by row My requirement is like below : I have a text file having comma seperated values of these records . OName OType SrcDB Sschema targetdb TSchema Load Dataype processY/N aa Table a e i m Y db2 y aa index b c d e N sql N ... (4 Replies)
Discussion started by: sailaja_80
4 Replies

8. UNIX for Dummies Questions & Answers

how to read the first and last column of the attached file

Dear All, I need a small script which will read from a txt file the first and and second and the last clumn of the file and determine how many are having +000 ,+024,+048 error codes. Please help me as soon as possible. Rgrds, A.Ali (2 Replies)
Discussion started by: samura
2 Replies

9. Shell Programming and Scripting

How to read a specific column into variable

Hi, I want to read the 3rd column of the v_string into a script variable v_3rd, can anyone help howto? v_string="This is for testing only" Thanks! Victor Cheung (2 Replies)
Discussion started by: victorcheung
2 Replies

10. Shell Programming and Scripting

how to read the column and print the values under that column

hi all:b:, how to read the column and print the values under that column ...?? file1 have something like this cat file1 ======= column1, column2,date,column3,column4..... 1, 23 , 12/02/2008,...... 2, 45, 14/05/2008,..... 3, 56, 16/03/2008,..... cat file2 =======... (6 Replies)
Discussion started by: gemini106
6 Replies
Login or Register to Ask a Question