Sponsored Content
Top Forums Shell Programming and Scripting awk or grep to search one column and output the other Post 302834923 by Manyaka on Saturday 20th of July 2013 04:29:05 PM
Old 07-20-2013
Hi Scott, thanks again for your help! I finally figured it out - found a very simple solution: I just had to add an ^ before "$row" to only search within the first column..

Code:
cat fileB | while read row ; do grep ^"$row" fileA | awk -F"\t" '{print $2}' > fileC


Last edited by Scott; 07-20-2013 at 05:31 PM.. Reason: Code tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search for a column by name in awk

Hi, I have a file that has many columns. Let us say "Employee_number" "Employee_name" "Salary". I want to display all entries in a column by giving all or part of the column name. For example if I input "name" I want all the employee names printed. Is it possible to do this in a simple manner... (2 Replies)
Discussion started by: kskkarthik
2 Replies

2. Shell Programming and Scripting

AWK in column search

Hi friends , I am new to unix ,need your help to fix this there is a ~ deliminated file. how to find the 5th column of the row. awk 'print $5 ' abc.txt it doesnot work . it works for table deliminated file. My data file is like the following manner. abc.txt -------- a~b~c~d~e~f... (3 Replies)
Discussion started by: imipsita.rath
3 Replies

3. Shell Programming and Scripting

To search a word in particular column using awk

I have a data in a file like this 1 praveen bmscollege 2 shishira bnmit 3 parthiva geethamce I want to search "praveen" using awk command i tried like this but i did not get awk `$2="praveen" {print $0} ` praveen.lst can anyone help me solving this problem in... (2 Replies)
Discussion started by: praveenhegde
2 Replies

4. Shell Programming and Scripting

awk : search last index in specific column

I am trying to search a given text in a file and find its last occurrence index. The task is to append the searched index in the same file but in a separate column. I am able to accomplish the task partially and looking for a solution. Following is the detailed description: names_file.txt ... (17 Replies)
Discussion started by: tarun.trehan
17 Replies

5. Shell Programming and Scripting

How to awk or grep the last column in file when date on column contains spaces?

Hi have a large spreadsheet which has 4 columns APM00111803814 server_2 96085 Corp IT Desktop and Apps APM00111803814 server_2 96085 Corp IT Desktop and Apps APM00111803814 server_2 96034 Storage Mgmt Team APM00111803814 server_2 96152 GWP... (6 Replies)
Discussion started by: kieranfoley
6 Replies

6. Shell Programming and Scripting

awk search pattern in column

Want to search a pattern in column using the below command which not helpful awk -F"\|" '$1 == '"${VAR}"' {print $1,$2}' file how to search using "==" with variable other than the below case. awk -F"\|" '$1 ~ /'"${VAR}"'/ {print $1,$2}' file (14 Replies)
Discussion started by: Roozo
14 Replies

7. Shell Programming and Scripting

Search/grep on row and column wise

Hello, I have a comma seperate metadata as follows: CITY ,COUNTY,STATE,COUNTRY NEW_YORK,NYC ,NY ,USA NEWARK ,ESSEX ,NJ ,USA CHICAGO ,COOK ,IL ,USA SEATTLE ,MINER ,WA ,USA In my process, I get two key values ie CITY NAME (can be one of the... (7 Replies)
Discussion started by: calredd
7 Replies

8. Shell Programming and Scripting

Search for string in column using variable: awk

I'm interested to match column pattern through awk using an external variable for data: -9 1:751343:T:A -9 0 T A 0.726 -5.408837e-03 9.576603e-03 7.967536e-01 5.722312e-01 -9 1:751756:T:C -9 0 T C 0.727 -5.360458e-03 9.579447e-03 7.966977e-01 5.757858e-01... (7 Replies)
Discussion started by: genome
7 Replies

9. Shell Programming and Scripting

Grep from FileA, search in FileB, edit FileC > Output

Hello, Similar question to my previous posts. I am sorry for the trouble... Just checked my old threads but I can not implement any solution into this case.. My aim is to grab each line in fileA, check it in fileB and merge with fileC (tab separated) in corresponding line as given below: FileA:... (2 Replies)
Discussion started by: baris35
2 Replies
FBSQL_FETCH_ARRAY(3)							 1						      FBSQL_FETCH_ARRAY(3)

fbsql_fetch_array - Fetch a result row as an associative array, a numeric array, or both

SYNOPSIS
array fbsql_fetch_array (resource $result, [int $result_type]) DESCRIPTION
fbsql_fetch_array(3) is a combination of fbsql_fetch_row(3) and fbsql_fetch_assoc(3). An important thing to note is that using fbsql_fetch_array(3) is NOT significantly slower than using fbsql_fetch_row(3), while it provides a significant added value. PARAMETERS
o $ result -A result identifier returned by fbsql_query(3) or fbsql_db_query(3). o $result_type - A constant and can take the following values: FBSQL_ASSOC, FBSQL_NUM, or FBSQL_BOTH. When using FBSQL_BOTH, in addition to storing the data in the numeric indices of the result array, it also stores the data in associative indices, using the field names as keys. RETURN VALUES
Returns an array that corresponds to the fetched row, or FALSE if there are no more rows. If two or more columns of the result have the same field names, the last column will take precedence. To access the other column(s) of the same name, you must the numeric index of the column or make an alias for the column. select t1.f1 as foo t2.f1 as bar from t1, t2 EXAMPLES
Example #1 fbsql_fetch_array(3) example <?php fbsql_connect($host, $user, $password); $result = fbsql_db_query("database", "select user_id, fullname from table"); while ($row = fbsql_fetch_array($result)) { echo "user_id: " . $row["user_id"] . "<br /> "; echo "user_id: " . $row[0] . "<br /> "; echo "fullname: " . $row["fullname"] . "<br /> "; echo "fullname: " . $row[1] . "<br /> "; } fbsql_free_result($result); ?> SEE ALSO
fbsql_fetch_row(3), fbsql_fetch_assoc(3), fbsql_fetch_object(3). PHP Documentation Group FBSQL_FETCH_ARRAY(3)
All times are GMT -4. The time now is 12:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy