Sponsored Content
Full Discussion: Loop column output
Special Forums UNIX Desktop Questions & Answers Loop column output Post 302254167 by rubin on Monday 3rd of November 2008 09:46:47 PM
Old 11-03-2008
You can work on something like this,

Code:
while read line
 do 
   set -- $line
   # you can also use echo -e 
   printf -- "-----\nThe number of the person is $1\nThe name of the person is $2\n$2 lives in a $3\n"
 done < file

Output

Code:
-----
The number of the person is 10
The name of the person is John
John lives in a house
-----
The number of the person is 20
The name of the person is Jane
Jane lives in a apt
-----
The number of the person is 30
The name of the person is Joe
Joe lives in a townhome

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

4 column tsv file, output 1 specific column

Hello all siteexplorer.search.yahoo.com can output results in tsv format, when opened in excel I get 4 columns. I would like to wget that file, which I can do. I would then like to pull the 2nd column and output it only. I've searched around and found a few bits and pieces but nothing I've... (6 Replies)
Discussion started by: casphar
6 Replies

2. Shell Programming and Scripting

top output for six processes with the same name, output changed from column to row

Hi, I have a system under test, and I use a script that does a ps. The output, is in the following format, it's basically the timestamp, followed by the rss and vsize. 09:03:57 68404 183656 68312 181944 69860 217360 67536 182564 69072 183172 69032 199276 09:04:27 68752 183292 70000 189020... (5 Replies)
Discussion started by: Bloke
5 Replies

3. Shell Programming and Scripting

Converting line output to column based output

Hi Guys, I am trying to convert a file which has a row based output to a column based output. My original file looks like this: 1 2 3 4 5 6 1 2 3 1 2 3 (8 Replies)
Discussion started by: npatwardhan
8 Replies

4. Shell Programming and Scripting

grep/awk on a single column in a for loop

Hi I'm trying to loop through a small list of id's and then pull out a few columns if the id matches that found in column 2 of the larger file. I managed to get one command to work awk -F " " '{if ($2 == '154080196') print $2,$3,$4}' tst.txt | less However, when I try it in a for loop I... (3 Replies)
Discussion started by: flotsam
3 Replies

5. Shell Programming and Scripting

loop in awk - column max for each column

Hello all, this should really be easy for you... I need AWK to print column maxima for each column of such input: Input: 1 2 3 1 2 1 1 3 2 1 1 2 Output should be: 2 2 3 3 This does the sum, but i need max instead: { for(i=1; i<=NF; i++) sum +=$i } END {for(i=1; i in sum;... (3 Replies)
Discussion started by: irrevocabile
3 Replies

6. Shell Programming and Scripting

while loop output

:wall:Hi I am a beginner to unix In a shell script i see the below code # set admin email so that you can get email ADMIN=someone@somewhere.com host=`hostname` date=`date` # set alert level 70% is default ALERT=70 df -h | grep / | grep -v '^Filesystem|tmpfs|cdrom' | awk '{ print... (1 Reply)
Discussion started by: prabhu_kumar
1 Replies

7. Shell Programming and Scripting

adding one more column in a loop

data1 1 0.01 3 5 1 0.6 2 1 data2 2 0.02 3 5 2 0.3 2 1 data3 3 0.01 3 5 3 0.01 2 1 output 1 0.01 data1 2 0.02 data2 3 0.01 data3 3 0.01 data3 I want to print 1st, 2nd column and the filename when second column is less than 5. (3 Replies)
Discussion started by: johnkim0806
3 Replies

8. Shell Programming and Scripting

Download images from the first column and rename it with the second column in a loop: Please help!

Dear Friends, I have a very little knowledge on shell scripting. I am stuck with a problem for which I need an expert advice. I have a .txt file "image_urls.txt" which contains the data like this imageurl ... (2 Replies)
Discussion started by: Praveen Pandit
2 Replies

9. UNIX for Dummies Questions & Answers

Print each output of loop in new column using awk or shell

I have this output from a loop a11 1,2 3,4 5,6 7,8 12,8 5,4 3,6 a12 10,11 12,13 15,18 20,22 a13 ... (3 Replies)
Discussion started by: maryre89
3 Replies

10. Shell Programming and Scripting

Awk: printing column using for loop

Hello: I've input data: Input data --- 3:60069:C:T 60069 C T 1 0 0 1 0 0 1 0 0 1 0 0 1 --- 3:60079:A:G 60079 A G 1 0 0 0.988 0.012 0 1 0 0 1 0 0 1 --- rs186476240:60157:G:A 60157 G A 1 0 0 1 0 0 1 0 0 1 0 0 1 I edit/make first few columns before numbers (6th column) and want to... (4 Replies)
Discussion started by: genome
4 Replies
STAG-HANDLE(1p) 					User Contributed Perl Documentation					   STAG-HANDLE(1p)

NAME
stag-handle - streams a stag file through a handler into a writer SYNOPSIS
stag-handle -w itext -c my-handler.pl myfile.xml > processed.itext stag-handle -w itext -p My::Parser -m My::Handler myfile.xml > processed.itext DESCRIPTION
will take a Stag compatible format (xml, sxpr or itext), turn the data into an event stream passing it through my-handler.pl ARGUMENTS
-help|h shows this document -module|m PERLMODULE A module that is used to transform the input events the module should inherit from Data::Stag::BaseHandler -unit|u NODE_NAME (you should always use this option if you specify -m) this is the unit that gets passed to the handler/transformer. this will get set automatically if you use the the -c, -s or -t options multiple units can be set -u foo -u bar -u boz -writer|w WRITER writer for final transformed tree; can be xml, sxpr or itext -module|m MODULE perl modules for handling events -codefile|c FILE a file containing a perlhashref containing event handlers - see below -sub|s PERL a perl hashref containing handlers -trap|t ELEMENT=SUB EXAMPLES
unix> cat my-handler.pl { person => sub { my ($self, $person) = @_; $person->set_fullname($person->get_firstname . ' ' . $person->get_lastname); $person; }, address => sub { my ($self, $address) = @_; # remove addresses altogether from processed file return; }, } perl v5.10.0 2008-12-23 STAG-HANDLE(1p)
All times are GMT -4. The time now is 01:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy