12-16-2008
read in variable data from another file - grep
Hello! I think this should be an easy solution. I have a large file with many fields of data. The first field has a unique identifier (a subject number) for every record for a chunk of data. Something like this:
Quote:
1 [Data] [Data] ...
1 [Data] [Data] ...
1 [Data] [Data] ...
1 [Data] [Data] ...
2 [Data] [Data] ...
2 [Data] [Data] ...
2 [Data] [Data] ...
2 [Data] [Data] ...
There were ten experimental conditions (ec), but the ec is identified by only one field in one record for each subject. I already ran a script to create a list of all subject numbers and their corresponding ec. For simplicity's sake (or so I think) I divided up that list by ec, so i now have numerous lists containing all of the subject numbers for each ec. I hope you can picture this.
Lets call my main data file "all.inq" and my lists "[0-9].lst"
I want to grep all the records in all.inq that begin with the numbers listed in 0.lst and put them in a file 0.inq, and then repeat the process for all other lists. This is probably a one liner, but I just don't know much about grep.
Thanks!
Chris
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am a FORTRAN guy and not a UNIX expert by any means so sorry if this sounds dumb, but all I want to do is have a UNIX script which reads data from a file (say 1000 lines worth, each row is a file name) and store it in an array to perform an operation on later. As maddeningly simple as this... (2 Replies)
Discussion started by: yorkdg
2 Replies
2. Shell Programming and Scripting
Hi,
I have a data file formatted like this:
Ex:
Mike 3434
Jack 481
Peter 12
Alan 926
I want to get this data into 2 variables: "Names" and "Numbers" that I can using one "for" loop to get the value as Names and Numbers
Like this:
for i in 0 1 2 3
do
echo $Names
echo... (12 Replies)
Discussion started by: fongthai
12 Replies
3. Shell Programming and Scripting
This is shell programming assignment.
It needs to create a file called .std_dbrc contains
STD_DBROOT=${HOME}/class/2031/Assgn3/STD_DB
(which includes all my simple database files)
and I am gonna use this .std_dbrc in my script file (read the data from the database files)
like this: .... (3 Replies)
Discussion started by: ccwq
3 Replies
4. UNIX for Advanced & Expert Users
I have 3 columns in an excel sheet.
c1 c2 c3
EIP_ACCOUNT SMALL_TS_01 select A.* from acc;
All the above 3 col shoud be passed a variable in the unix code.
1.How to read an excel file
2.How to pass these data as variable to the unic script (1 Reply)
Discussion started by: Anne Grace
1 Replies
5. Shell Programming and Scripting
Hi Frnds...
I have an input file name.txt and another file named as source.. name.txt is having only one column and source is having around 25 columns...i need to read from name.txt line by line and search it in source file and then save the result in results file..
I have a rough idea about the... (15 Replies)
Discussion started by: ektubbe
15 Replies
6. Shell Programming and Scripting
In the hello.htm have the sentenses:
Hello $name
How are you?
The perl script:
$name = "David";
open(HEADER,"hello.htm");
while(<HEADER>) { $html .= $_; }
close(HEADER);
print "$html";I making something about template. But it can't process the $name variable. (4 Replies)
Discussion started by: natong
4 Replies
7. Shell Programming and Scripting
I need to read a text file that contain columns of data, i need to read 1st column as a function to call, and others are the data i need to get into a ksh script.
I am quite new to ksh scripting, i am not very sure how to read each row line by line and the data in each columns of that line, set... (3 Replies)
Discussion started by: gavin_L
3 Replies
8. Shell Programming and Scripting
I have input data looks like this which is a part of a csv file
7,1265,76548,"0102:04"
8,1266,76545,"0112:04"
I need to make the output data should look like this and the output data will be part of text file:
7|1265000 |7654899 |A|
8|12660000 |76545999 |B|
The logic behind the... (6 Replies)
Discussion started by: RJG
6 Replies
9. Shell Programming and Scripting
Hi Team,
in /tmp folder i have thousands of log files i want to read each file and grep a value called "Calling This".
Each logfile name is different but it ends with .log.
How can i achieve this?
Please excuse if i did any mistake by not following forum standards. I will surely follow... (10 Replies)
Discussion started by: darling
10 Replies
10. Shell Programming and Scripting
We have the data looks like below in a log file.
I want to generat files based on the string between two hash(#) symbol like below
Source:
#ext1#test1.tale2 drop
#ext1#test11.tale21 drop
#ext1#test123.tale21 drop
#ext2#test1.tale21 drop
#ext2#test12.tale21 drop
#ext3#test11.tale21 drop... (5 Replies)
Discussion started by: Sanjeev G
5 Replies
LEARN ABOUT SUSE
data::grove::parent
Data::Grove::Parent(3) User Contributed Perl Documentation Data::Grove::Parent(3)
NAME
Data::Grove::Parent - provide parent properties to Data::Grove objects
SYNOPSIS
use Data::Grove::Parent;
$root = $object->root;
$rootpath = $object->rootpath;
$tied = $object->add_magic([ $parent ]);
$node = Data::Grove::Parent->new($hash [, $parent]);
$node_list = Data::Grove::ParentList->new($array [, $parent]);
DESCRIPTION
Data::Grove::Parent is an extension to Data::Grove that adds `"Parent"' and `"Raw"' properties to Data::Grove objects and methods for
returning the root node of a grove, a list of nodes between and including the root node and the current node, and a method that creates
parented nodes.
Data::Grove::Parent works by creating a Perl ``tied'' object that contains a parent reference (`"Parent"') and a reference to the original
Data::Grove object (`"Raw"'). Tying-magic is used so that every time you reference the Data::Grove::Parent object it actually references
the underlying raw object.
When you retrieve a list or a property of the Raw object, Data::Grove::Parent automatically adds magic to the returned list or node. This
means you only call `add_magic()' once to create the first Data::Grove::Parent object and then use the grove objects like you normally
would.
The most obvious use of this is so you don't have to call a `"delete"' method when you want to release a grove or part of a grove; since
Data::Grove and Data::Grove::Parent objects have no cyclic references, Perl can garbage collect them normally.
A secondary use is to allow you to reuse grove or property set fragments in multiple trees. WARNING: Data::Grove currently does not
protect you from creating your own cyclic references! This could lead to infinite loops if you don't take care to avoid them.
METHODS
$object->root()
$object->rootpath()
`"root()"' returns the root node if `$object' is a `"Data::Grove::Parent"' object. `"rootpath()"' returns an array of all the nodes
between and including the root node and `$object'.
$tied = $object->add_magic([ $parent ])
`"add_magic()"' returns a "Data::Grove::Parent" object with `$object' as it's `"Raw"' object. If `$parent' is given, that becomes the
tied object's parent object.
AUTHOR
Ken MacLeod, ken@bitsko.slc.ut.us
SEE ALSO
perl(1), Data::Grove(3)
perl v5.12.1 2003-10-21 Data::Grove::Parent(3)