Can someone tell me what this is doing? I know it is reading records from a table and puts them in a hash. How do I print out, let's say, the first 5 columns of data (assuming columns are named col1, col2, ...)?
Hello,
I have text file while looks this
test1
test2
test3
test4
test5
test6
and if I want to parse it and make new file which would like this
test1 test2
test3 test4
test5 test6
How can I do this in korn shell script
Thanks (9 Replies)
sorry if im not asking inthe right spot but, how do you turn the beeping off every time you hit a key onthe keyboard. I tried the click -n but it told me it didnt recognize click
any help would be greatly appreciated ( the beeping is not going over well in the surrounding cubicles)
thank you... (4 Replies)
Hello everyone,
Just started UNIX today! In our school we use solaris. I just want to know how do I setup Solaris 10 not the GUI one, the one where you have to type the commands like ECHO, ls, pwd, etc... I have windows xp and I also have vmware.
I hope I am not missing anything! :p (4 Replies)
Hello everyone,
I am having to do a lot of perl scripting these days and I am learning a lot.
I have this problem
I want to move files from a folder and all its sub folders to one parent folder, they are all .gz files..
there is folder1\folder2\*.gz
and there are about 50 folders... (1 Reply)
Hi,
I am new to programming and also to perl..But i know 'perl' can come to my rescue, But I am stuck at many places and need help..any small help is much appreciated... below is the description of what i intend to acheive with my script.
I have a files named in this format... (13 Replies)
I have the following question in perl, I have come up with couple of solutions,Perl gurus please help me find the best answer to my question?
You have a PERL database named DataEntryData, and you need to separate out the various values from the DB entry $item, delimited by the ^ sumbol. There... (2 Replies)
Hi there
apologies for the really basic question but if i have a variable called $string that I want to run a regex against and output to another variable ...how do i do it, I know that if i wanted to alter the current $string variable i would do
$string=~ s/old/new/g;
but i kind of want... (2 Replies)
Hi all,
I am sure this is very simple but I cant quite get it.
I am trying to search textfile1.txt for a string then take the results of the search and append the result to textfile3.txt
So far I have used
$ find file1.txt -exec grep "string i am looking for" '{}' \; -print
this... (2 Replies)
I am completely new to perl programming. My father is helping me learn said programming language. However, I am stuck on one of the assignments he has given me, and I can't find very much help with it via google, either because I have a tiny attention span, or because I can be very very dense.
... (4 Replies)
I was looking through some code online and came accross this...
ls *.txt | grep text1 | cat file1 – file2 | `echo wc –l`
I know what "ls|grep text1" does and I know a word count gets echoed but beyond that I am confused. Please use layman terms as much as possible as I am a newbie. (8 Replies)
Discussion started by: elohssa
8 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)