07-20-2012
For loop question
I have two files. In file one, there are many columns, but only two of interest to me. Column 1 contains a list of individuals, defined by an ID number. Column 10 contains the diagnosis that each individual has (I am a physician). All together, there are 3000 lines in this file, one line per individual.
Column1.........Column10
PT1234 DiseaseA
PT5678 DiseaseB
PT2345 DiseaseA
PT4567 DiseaseA
In file 2 there are two columns. As before there are 3000 lines, one line per individual. The information in the columns in this file is not important other than that somewhere in each line (for some lines in column1, for some lines in column2) the individuals ID appears.
For example, the row in file2 that corresponds to the first row in file1 might be
sldbris-%*PT1234xthb SW-efgs
What I would like to do is create a third file that is the same as file 2 except it has a third column for the diagnosis for the ID (ie, the string PT#### that appears in that line).
Please help, thank you.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi,
how would i go about making a loop which gets each line from a single text file, set it to a variable and then print it to screen?
thanks
eg:
#!/bin/sh
FILE="somefile.txt"
text_line=""
what kind of loop would use here? (18 Replies)
Discussion started by: strike
18 Replies
2. Shell Programming and Scripting
HI ALL
How to read first 10 line from a file using any method (5 Replies)
Discussion started by: aliahsan81
5 Replies
3. Shell Programming and Scripting
Hi all
Sorry for the basic question, but i am writing a shell script to get around a slightly flaky binary that ships with one of our servers. This particular utility randomly generates the correct information and could work first time or may work on the 12th or 100th attempt etc !.... (4 Replies)
Discussion started by: rethink
4 Replies
4. Shell Programming and Scripting
I'm improving the way an existing script handles arrays, but the results aren't what I had in mind:
e="Too many consecutive errors... System is probably unstable!"
e="Cancelable Timer Wait Failed!"
for errcd in ${e}
do
echo ${errcd}
done
The for loop interprets the spaces... (2 Replies)
Discussion started by: ironhalo
2 Replies
5. Shell Programming and Scripting
hey guys what im trying to do is do a simple script that will ask for a password and on the 5th time it says access denied if the right password is still not entered this is what i have so far can anyone help me im not good with scripting
thanks in advance
#!/bin/bash
secretname=secret... (2 Replies)
Discussion started by: randallrivy11
2 Replies
6. Shell Programming and Scripting
I am struggling with the for loop. I have a file name heros.txt and I would like to go through a list in file where.txt and see if I can find the name from where inside heros.
One of the problems that I am having is I dont understand how to setup the for loop to find the list to search.:wall:
... (6 Replies)
Discussion started by: captaindoogles
6 Replies
7. Shell Programming and Scripting
Hi,
I'm trying to put together a small script that will read a txt file that contains a list of two columns. Each column is the name of a folder..
e.g.
AIX Server1
AIX Server2
AIX Server3
$ for i in `cat /opt/apacheprod/scripts/input/copy_list.txt`
do
PLATFORMVAR=`awk ' { print $1 } '... (7 Replies)
Discussion started by: Jazmania
7 Replies
8. Shell Programming and Scripting
Hi,
I have a requirement where I have to check for 10 files in Unix location. If all of the files present in that directory then i have execute another process.
can you help me resolving this issue.
sample
location
/home/usr
abc.txt
cde.txt
aaaa.txt
lll.txt
ooo.txt
if all the... (3 Replies)
Discussion started by: manasvi24
3 Replies
9. UNIX for Dummies Questions & Answers
Hi,
I would really appreciate some help with manipulating a file.
Here is my input file:
SNP_1 : 1 SNP_11 : 1
SNP_2 -0.12 1 SNP_12 -0.3472 1
SNP_3 -0.708 1 SNP_13 0.5037 1
SNP_4 1.492 0.5 SNP_14 -0.0685 1
SNP_5 1.27 0.5 SNP_15 0.547 ... (3 Replies)
Discussion started by: zajtat
3 Replies
10. UNIX for Dummies Questions & Answers
Hi,
I have code like below
disk_list=$(ls /root/file1)
for disk in $disk_list
do
pvcreate $i
done
I know what pvcreate command does, but I do not understand what this $i do here. can someone please explain. (2 Replies)
Discussion started by: stew
2 Replies
LEARN ABOUT PHP
cubrid_num_cols
CUBRID_NUM_COLS(3) 1 CUBRID_NUM_COLS(3)
cubrid_num_cols - Return the number of columns in the result set
SYNOPSIS
int cubrid_num_cols (resource $result)
DESCRIPTION
The cubrid_num_cols(3) function is used to get the number of columns from the query result. It can only be used when the query executed is
a select statement.
PARAMETERS
o $result
-Result.
RETURN VALUES
Number of columns, when process is successful.
FALSE, if SQL statement is not SELECT.
EXAMPLES
Example #1
cubrid_num_cols(3) example
<?php
$conn = cubrid_connect("localhost", 33000, "demodb", "dba");
$req = cubrid_execute($conn, "SELECT * FROM code");
$row_num = cubrid_num_rows($req);
$col_num = cubrid_num_cols($req);
printf("Row Num: %d
Column Num: %d
", $row_num, $col_num);
cubrid_disconnect($conn);
?>
The above example will output:
Row Num: 6
Column Num: 2
SEE ALSO
cubrid_execute(3), cubrid_num_rows(3).
PHP Documentation Group CUBRID_NUM_COLS(3)