Just want to ask if there is a shorter hand to doing this one liner
Hi all,
In Oracle, I am using SQL*Plus and selecting all rows in a table and spooling to a file as pipe delimited. I have to use pagesize 0 but unfortunately, using this option excludes the header and I can't get around having it to display the header fields.
So to get around this, I have to create some header file and combine the output from the non-header output and the header only output. This is working fine, I am just curious if there is a shorter version of the command that I am using to create the header line.
Here is what I am doing at the moment.
Below is the header text file doing a describe of the table:
And this is the command that I am using to convert the content of a.txt to a header file
Then I do a cat a.header.txt a.out.txt > a.xls. Sample a.out.txt is as below:
Final output is as below:
While what am doing at the moment works fine, just want to know if there is a more shorter way of doing it :-)
How do you get an awk output into columns i.e.
awk (print $1,$2,$3) doesn't come out into nice columns but lots of lines of txt want something more like.
I am crap
at unix so
give me a
hand thx Rich (3 Replies)
Hi,
I remember once seeing a way to get the left most string in a word.
Let's say: a="First.Second.Third" (separated by dot)
echo ${a#*.} shows --> Second.Third
echo ${a##*.} shows --> Third
How do I get the the left most string "First" Or "First.Second" ???
Tried to replace #... (2 Replies)
i have a script in sh. with awk, e.g. want to list all the contents of a subdirectory an a tabular way.
ej: outoput
directory1
subdirectory1 subdirectory2 subdirectory3
file1 filen file2 filez
file2 ... filen+1 ... (1 Reply)
What's the correct way to change the initramfs file that's used during boot?
I know that it's a gzipped cpio archive, but when I gunzip, extract, re-archive (without changing any files), and gzip, then the result is that the system does not boot any more. And I even set the cpio archive type.
... (18 Replies)
Hi Folks,
I know my code works, but I'm still a newbie at arrays and how they function.
Is there is shorter way to write my code? I'm taking averages in multiple files and concatenating output into 1 file.
TIA!
for file in *;
do
awk -F"\t" '{a1+=$1}{a2+=$2}{a3+=$3} {a4+=$4}{a5+=$5}... (1 Reply)
Hello,
I have the following data file structure:
1234 text
2345 text
3456 text text text
4567 text text text
5678 text text text
6789 text text text
I simply want to delete all of the lines that only have one text column (i.e. the first two lines in this case). The output would be:... (1 Reply)
Thanks for giving your time and effort to answer questions and helping newbies like me understand awk.
I have a huge file, millions of lines, so perl takes quite a bit of time, I'd like to convert these perl one liners to awk.
Basically I'd like all lines with ISA sandwiched between... (9 Replies)
Hello everyone,
I searched the forum looking for answers to this but I could not pinpoint exactly what I need as I keep having trouble.
I have many files each having two columns and hundreds of rows.
first column is a string (can have many words) and the second column is a number.The files are... (5 Replies)
Hello,
I am working on an Urdu to Hindi dictionary which has the following structure:
a=b
a=c
n=d
n=q
and so on.
i.e. Headword separated from gloss by a =
I am giving below a live sample
بتا=बता
بتا=बित्ता
بتا=बुत्ता
بتان=बतान
بتان=बितान
بتانا=बिताना
I need the following... (3 Replies)
Discussion started by: gimley
3 Replies
LEARN ABOUT DEBIAN
sql::translator::parser::dbi
SQL::Translator::Parser::DBI(3pm) User Contributed Perl Documentation SQL::Translator::Parser::DBI(3pm)NAME
SQL::Translator::Parser::DBI - "parser" for DBI handles
SYNOPSIS
use DBI;
use SQL::Translator;
my $dbh = DBI->connect('dsn', 'user', 'pass',
{
RaiseError => 1,
FetchHashKeyName => 'NAME_lc',
}
);
my $translator = SQL::Translator->new(
parser => 'DBI',
dbh => $dbh,
);
Or:
use SQL::Translator;
my $translator = SQL::Translator->new(
parser => 'DBI',
parser_args => {
dsn => 'dbi:mysql:FOO',
db_user => 'guest',
db_password => 'password',
}
);
DESCRIPTION
This parser accepts an open database handle (or the arguments to create one) and queries the database directly for the information.
The following are acceptable arguments:
o dbh
An open DBI database handle. NB: Be sure to create the database with the "FetchHashKeyName => 'NAME_lc'" option as all the DBI
parsers expect lowercased column names.
o dsn
The DSN to use for connecting to a database.
o db_user
The user name to use for connecting to a database.
o db_password
The password to use for connecting to a database.
There is no need to specify which type of database you are querying as this is determined automatically by inspecting
$dbh->{'Driver'}{'Name'}. If a parser exists for your database, it will be used automatically; if not, the code will fail automatically
(and you can write the parser and contribute it to the project!).
Currently parsers exist for the following databases:
o MySQL
o SQLite
o Sybase
o PostgreSQL (still experimental)
Most of these parsers are able to query the database directly for the structure rather than parsing a text file. For large schemas, this
is probably orders of magnitude faster than traditional parsing (which uses Parse::RecDescent, an amazing module but really quite slow).
Though no Oracle parser currently exists, it would be fairly easy to query an Oracle database directly by using DDL::Oracle to generate a
DDL for the schema and then using the normal Oracle parser on this. Perhaps future versions of SQL::Translator will include the ability to
query Oracle directly and skip the parsing of a text file, too.
AUTHOR
Ken Y. Clark <kclark@cpan.org>.
SEE ALSO
DBI, SQL::Translator.
perl v5.14.2 2012-05-01 SQL::Translator::Parser::DBI(3pm)