Sponsored Content
Top Forums Shell Programming and Scripting first row data into variables Post 302084919 by Dhruva on Monday 14th of August 2006 07:54:13 AM
Old 08-14-2006
The following script will capture the fields of first line into v_col1,v_col2 and v_col3.you can check with echo these variables.this script is wriiten with assumption that there are only 3 fields in first line and they are comma(,) seperated.

Code:
line1=`sed '1q' data_filename`
v_col1=`echo $line1 | awk -F"," '{print $1}'`
v_col2=`echo $line1 | awk -F"," '{print $2}'`
v_col3=`echo $line1 | awk -F"," '{print $3}'`
echo $v_col1
echo $v_col2 
echo $v_col3

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to insert data befor some field in a row of data depending up on values in row

Hi I need to do some thing like "find and insert before that " in a file which contains many records. This will be clear with the following example. The original data record should be some thing like this 60119827 RTMS_LOCATION_CDR INSTANT_POSITION_QUERY 1236574686123083rtmssrv7 ... (8 Replies)
Discussion started by: aemunathan
8 Replies

2. Shell Programming and Scripting

Add value of each row when each row has different data ype

Guys -- I am noob and I am really strugging on this one. I cant even write the pseudo code for it. I have a file that spits values in individual rows as such: file: user date type size joe 2005-25-09 log 1 joe 2005-25-09 snd 10 joe 2005-25-09 rcd 12 joe 2005-24-09 log 2 joe... (1 Reply)
Discussion started by: made2last
1 Replies

3. Shell Programming and Scripting

Convert row data to column data

Hi Guys, I have a file as follows: a 1 b 786 c 90709 d 99 a 9875 b 989 c 887 d 111 I want: a 1 9875 b 786 989 (3 Replies)
Discussion started by: npatwardhan
3 Replies

4. Shell Programming and Scripting

Moving data from a specified column/row to another column/row

Hello, I have an input file like the following: 11_3_4 2_1_35 3_15__ _16989 Where '_' is a space. The data is in a table. Is there a way for the program to prompt the user for x1,y1 and x2,y2, where x1,y1 is the desired number (for example x=6 y=4 is a value of 4) and move to a desired spot... (2 Replies)
Discussion started by: jl487
2 Replies

5. Shell Programming and Scripting

Error in fetching multiple row values into variables

Hello Team, In the below code....The variabe values are not fetch from input table into SELECT statements. =========================== #!/usr/bash DATABASE=XXXXX inputFILE=$1 db2 connect to $DATABASE TABLENAME=`echo $inputFILE|awk '{print $1}'` COLUMNNAME=`echo $inputFILE|awk... (2 Replies)
Discussion started by: rocking77
2 Replies

6. UNIX for Advanced & Expert Users

Convert column data to row data using shell script

Hi, I want to convert a 3-column data to 3-row data using shell script. Any suggestion in this regard is highly appreciated. Thanks. (4 Replies)
Discussion started by: sktkpl
4 Replies

7. Shell Programming and Scripting

Help with multiple variables into one row in CSV!

I'm new to shell scripting so I'm guessing I'm just not looking at this from the correct angle as this has to be a common task. What I'm trying to do is take data I've compiled for servers (Name, IPs, HBA WWN's, Storage, etc) and trying to turn that into one row in a CSV file. So File1:... (3 Replies)
Discussion started by: The_Grim_Coder
3 Replies

8. Emergency UNIX and Linux Support

[Solved] Mysql - Take data from row and copy it to another row

Sorry if I repost my question in this section, but I'm really in a hurry since I have to finish my work... :( Dear community, I have a table with two rows like: Row1 Row2 ======= ======= 7,3 text 1 1,3 text 2 1,2,3 blabla What i need to do is add/copy... (2 Replies)
Discussion started by: Lord Spectre
2 Replies

9. Shell Programming and Scripting

Column to Row Data.

HI Guys, I have below Input :- X L1 5 Y L1 10 Z L1 15 X L2 20 Y L2 12 Z L2 15 X L3 100 Y L3 Z L3 300 Output:- ID L1 L2 L3 X 5 10 15 Y 20 12 15 Z 100 Null 300 (11 Replies)
Discussion started by: pareshkp
11 Replies
Text::SimpleTable(3pm)					User Contributed Perl Documentation				    Text::SimpleTable(3pm)

NAME
Text::SimpleTable - Simple Eyecandy ASCII Tables SYNOPSIS
use Text::SimpleTable; my $t1 = Text::SimpleTable->new(5, 10); $t1->row('foobarbaz', 'yadayadayada'); print $t1->draw; .-------+------------. | foob- | yadayaday- | | arbaz | ada | '-------+------------' my $t2 = Text::SimpleTable->new([5, 'Foo'], [10, 'Bar']); $t2->row('foobarbaz', 'yadayadayada'); $t2->row('barbarbarbarbar', 'yada'); print $t2->draw; .-------+------------. | Foo | Bar | +-------+------------+ | foob- | yadayaday- | | arbaz | ada | | barb- | yada | | arba- | | | rbar- | | | bar | | '-------+------------' my $t3 = Text::SimpleTable->new([5, 'Foo'], [10, 'Bar']); $t3->row('foobarbaz', 'yadayadayada'); $t3->hr; $t3->row('barbarbarbarbar', 'yada'); print $t3->draw; .-------+------------. | Foo | Bar | +-------+------------+ | foob- | yadayaday- | | arbaz | ada | +-------+------------+ | barb- | yada | | arba- | | | rbar- | | | bar | | '-------+------------' DESCRIPTION
Simple eyecandy ASCII tables. METHODS
Text::SimpleTable implements the following methods. "new" my $t = Text::SimpleTable->new(5, 10); my $t = Text::SimpleTable->new([5, 'Col1', 10, 'Col2']); "draw" my $ascii = $t->draw; "hr" $t = $t->hr; "row" $t = $t->row('col1 data', 'col2 data'); AUTHOR
Sebastian Riedel, "sri@cpan.org". CREDITS
In alphabetical order: Brian Cassidy COPYRIGHT
Copyright (C) 2005-2009, Sebastian Riedel. This program is free software, you can redistribute it and/or modify it under the same terms as Perl 5.10. perl v5.10.0 2009-07-03 Text::SimpleTable(3pm)
All times are GMT -4. The time now is 03:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy