Read a file and search a value in another file create third file using AWK
Hi,
I have two files with the format shown below. I need to read first field(value before comma) from file 1 and search for a record in file 2 that has the same value in the field "KEY=" and write the complete record of file 2 with corresponding field 2 of the first file in to result file.
I wrote awk command for it but my code doesn't take care of duplicate records. please look at first two records in File 1 in the above example, field 1 is same but field 2 is different. In the same way I will have two exact same entries (same KEY value) in File 2 and I need to assign different values.
Hi All,
Please help me in creating files through K-shell scripts.
I am having one file in this format.
OWNER.TABLE_NAME
OWNER.TABLE_NAME1
OWNER1.TABLE_NAME
OWNER1.TABLE_NAME1
I want to read the above file and create new file through k shell script.
The new file should looks like this.... (4 Replies)
Hi Experts.
I need to list the file and the filename comes from the file ListOfFile.txt.
Basicly I have a filename "ListOfFile.txt" and it contain
Example of ListOfFile.txt
/home/Dave/Program/Tran1.P
/home/Dave/Program/Tran2.P
/home/Dave/Program/Tran3.P
/home/Dave/Program/Tran4.P... (7 Replies)
Hi there, I have a text file with several colums separated by "|;#" I need to search the file extracting all columns starting with the value of "1" or "2" saving in a separate file just the first 7 columns of each row maching the criteria, with replacement of the saparators in the nearly created... (4 Replies)
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)
Hello folks, I have another doozy. I have two files. The first file has four fields in it. These four fields map to different locations in my second file. What I want to do is read the master file (file 2 - 23 fields) and compare each line against each record in file 1. If I get a match in all four... (4 Replies)
Hi Forum.
I did some google search on what I'm trying to do but I cannot get my code to work correctly. I have 2 files which are very large and I want to read text from file1 and search in file2 - if present, keep the records.
I've tried fgrep -f file1 file2 but it is too slow.
File1:... (10 Replies)
In the below bash a file is downloaded when the program is opened and then that file is searched based on user input and the result is written to a new file.
For example, the bash is opened and the download.txt is downloaded, the user then enters the id (NA04520). The id is used to search... (5 Replies)
Hi guys,
I have a text file named file1.txt that is formatted like this:
001 , ID , 20000
002 , Name , Brandon
003 , Phone_Number , 616-234-1999
004 , SSNumber , 234-23-234
005 , Model , Toyota
007 , Engine ,V8
008 , GPS , OFF
and I have file2.txt formatted like this:
... (2 Replies)
I have files named with different prefixes. From each I want to extract the first line containing a specific string, and then print that line along with the prefix.
I've tried to do this with a while loop, but instead of printing the prefix I print the first line of the file twice.
Files:... (3 Replies)
Hello,
I have some large text files that look like,
putrescine
Mrv1583 01041713302D
6 5 0 0 0 0 999 V2000
2.0928 -0.2063 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
5.6650 0.2063 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
3.5217 ... (3 Replies)
Discussion started by: LMHmedchem
3 Replies
LEARN ABOUT DEBIAN
dbs_update
DBS_UPDATE(1p) User Contributed Perl Documentation DBS_UPDATE(1p)NAME
dbs_update - Update SQL Databases
DESCRIPTION
dbs_update is an utility to update SQL databases from text files.
FORMAT OF THE TEXT FILES
dbs_update assumes that each line of the input contains a data record and that the field within the records are separated by tabulators.
You can tell dbs_update about the input format with the --format option.
The first field of the data record is used as table specification. These consists of the table name and optionally the index of starting
column, separated by a dot.
Alternatively dbs_update can read the column names from the first line of input (see the -h/--headline option). These can even be aliases
for the real column names (see the -m/--map option).
COMMAND LINE PARAMETERS
Required command line parameters are the DBI driver ("Pg" for Postgres or "mysql" for MySQL) and the database name. The third parameter is
optionally and specifies the database user and/or the host where the database resides ("racke", "racke@linuxia.de" or "@linuxia.de").
OPTIONS --cleanse
Removes all records which remain unaffected from the update process. The same result as deleting all records from the table first and then
running dbs_update, but the table is not empty in the meantime.
-c COLUMN,COLUMN,..., --columns=COLUMN,COLUMN,...
Update only the table columns given by the COLUMN parameters. To exclude columns from the update prepend "!" or "^" to the parameters.
--rows=ROW,ROW,...
Update only the input rows given by the ROW parameters. The first row is 1 where headlines doesn't count. To exclude rows from the update
prepend "!" or "^" to the parameters.
-f FILE, --file=FILE
Reads records from file FILE instead of from standard input.
--format=FORMAT[SEPCHAR]
Assumes FORMAT as format for the input. Only CSV can be specified for now, default is TAB. The default field separator for CSV is a comma,
you may change this by appending the separator to the format.
-h, --headline
Reads the column names from the first line of the input instead of dedicting them from the database layout. Requires the -t/--table option.
-k COUNT, -k KEY,KEY,..., --keys=COUNT, --keys=KEY,KEY,...
Specifies the keys for the table(s) either as the number of columns used as keys or by specifying them explicitly as comma separated argu-
ments to the option. This is used for the detection of existing records.
-m ALIASDEF, --map=ALIASDEF
Maps the names found in the first line of input to the actual column names in the database. The alias and the column name are separated
with "=" signs and the different entries are separated by ";" signs, e.g. "Art-No.=code;Short Description=shortdescr'".
--map-filter=FILTER
Applies a filter to the column names read from the input file. Currently there is only the "lc" filter available.
--match-sql=FIELD:{STATEMENT}
Updates only records where the value of the column FIELD is in the result set of the SQL statement STATEMENT, e.g. "category:{select dis-
tinct name from categories}".
-o, --update-only
Updates existing database entries only, stops if it detects new ones.
-r ROUTINE, --routine=ROUTINE
Applies ROUTINE to any data record. ROUTINE must be a subroutine. dbs_update passes the table name and a hash reference to this subrou-
tine. The keys of the hash are the column names and the values are the corresponding field values. If the return value of ROUTINE is not a
truth value, the data record will be skipped.
"sub {my ($table, $valref) = @_;
unless (defined $$valref{country} && $$valref{country} !~ /S/) {
$$valref{country} = "Germany";
}
1; }"
--skipbadlines
Lines not matching the assumed format are ignored. Without this option, dbs_update simply stops.
-t TABLE, --table=TABLE
Uses TABLE as table name for all records instead of the first field name.
AUTHOR
Stefan Hornburg (Racke), racke@linuxia.de
SEE ALSO perl(1), DBIx::Easy(3)perl v5.8.8 2007-02-01 DBS_UPDATE(1p)