Sponsored Content
Full Discussion: Alias to awk BEGIN statement
Top Forums Shell Programming and Scripting Alias to awk BEGIN statement Post 302260687 by fpmurphy on Friday 21st of November 2008 12:42:45 PM
Old 11-21-2008
Maybe I am missing something here but it seems to me that the easiest way to achieve what you want to do is to customise your editor. For example if you use vi, you can easily add a macro to insert a string anywhere you want to. For example
Code:
:map 9 i{OFS="\t";FS="\t"}<control-v><escape><enter>

will insert the string '{OFS="\t";FS="\t"}' anytime the 9 key is pressed.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Another question on awk - Begin statement

Hi, I've a question on awk. In English I want to: (a) open a file, (b) search through the file for records where length of field15 > 20 characters and (c) print out some fields in the record. I've written the following and it works OK. The trouble is this will ALWAYS write out the column... (5 Replies)
Discussion started by: eff_cee
5 Replies

2. Shell Programming and Scripting

AWK not processing BEGIN directive

Hello I have the following awk script: BEGIN { {FS = " " } {print "\t\tIllegal Loggon Attempts on MAIL\n"} {"date" | getline d} {printf "\t %s\n",d } {print "Loggon Name\t\t\t Number of Attempts\n"} ... (2 Replies)
Discussion started by: mojoman
2 Replies

3. Shell Programming and Scripting

awk getting stuck after BEGIN

I am beginner in awk awk 'BEGIN{for(i=1;(getline<"opnoise")>0;i++) arr=$1}{print arr}' In the above script, opnoise is a file, I am reading it into an array and then printing the value corresponding to index 20. Well this is not my real objective, but I have posted this example to describe... (1 Reply)
Discussion started by: akshaykr2
1 Replies

4. Shell Programming and Scripting

awk BEGIN problem

awk 'BEGIN { print "line one\nline two\nline three" }' After ./awktest.sh Usage: awk -f progfile file ... Usage: awk 'program' file ... POSIX options: GNU long options: -f progfile --file=progfile -F fs --field-separator=fs -v var=val ... (7 Replies)
Discussion started by: cola
7 Replies

5. Shell Programming and Scripting

BEGIN and END format in awk

I'm new to awk, trying to understand the basics. I'm trying to reset the counter everytime the program gets a new file to check. I figured in the BEGIN part it would work, but it doesn't. #!/bin/awk -f BEGIN {counter=0} { sum=0 for ( i=1; i<=NF;... (1 Reply)
Discussion started by: guitarist684
1 Replies

6. UNIX for Dummies Questions & Answers

awk search with begin

Hi, I have written below script to begin if the line has n #!/bin/ksh /usr/xpg4/bin/awk {/ n / 'BEGIN {X = "01"; X = "02"; X = "03"; X = "04"; X = "05"; X = "06"; X = "07"; X = "08"; X ="09"; X = "10"; X = "11"; X = "12"; };} NR > 1 {print $1 "\t" $5 "," X "," $6 " " $7}'} input.txt |... (9 Replies)
Discussion started by: stew
9 Replies

7. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies

8. Shell Programming and Scripting

Awk: BEGIN: prints nothing

My code fails to do anything if I've BEGIN block in it: Run the awk script as: awk -f ~/bin/sum_dupli_gene.awk make_gene_probe.txt #!/usr/bin/awk -f BEGIN { print ARGV #--loads of stuff } END{ #more stuff } (14 Replies)
Discussion started by: genome
14 Replies

9. UNIX for Beginners Questions & Answers

Awk: use variable defined in begin

Hi there, I'm working with file more than 400K lines, 60 columns. Column count is going to be multiple of 12: 60, 12, 72 or so. NF/12 gives me on how many iterations I've to do to check certain value. For example: 7, 14th if only 24 columns in file. 7th, 14th and 21st if 36 columns in... (6 Replies)
Discussion started by: genome
6 Replies

10. Shell Programming and Scripting

Usage of a variable in awk BEGIN

Hi, diffcount=`awk 'BEGIN { while ( getline < "/scripts/matt/text.server1.reference" ) { arr++ } } { if (!( $0 in arr ) ) { print } }' $TMPDIR/$(basename $0 .sh) | wc -l` if ]; then OK="OK - No change in the interfaces status" elif ]; then DIFF=`awk 'BEGIN {... (4 Replies)
Discussion started by: nms
4 Replies
QSqlPropertyMap(3qt)													      QSqlPropertyMap(3qt)

NAME
QSqlPropertyMap - Used to map widgets to SQL fields SYNOPSIS
#include <qsqlpropertymap.h> Public Members QSqlPropertyMap () virtual ~QSqlPropertyMap () QVariant property ( QWidget * widget ) virtual void setProperty ( QWidget * widget, const QVariant & value ) void insert ( const QString & classname, const QString & property ) void remove ( const QString & classname ) Static Public Members QSqlPropertyMap * defaultMap () void installDefaultMap ( QSqlPropertyMap * map ) DESCRIPTION
The QSqlPropertyMap class is used to map widgets to SQL fields. The SQL module uses Qt object properties to insert and extract values from editor widgets. This class is used to map editors to SQL fields. This works by associating SQL editor class names to the properties used to insert and extract values to/from the editor. For example, a QLineEdit can be used to edit text strings and other data types in QDataTables or QSqlForms. Several properties are defined in QLineEdit, but only the text property is used to insert and extract text from a QLineEdit. Both QDataTable and QSqlForm use the global QSqlPropertyMap for inserting and extracting values to and from an editor widget. The global property map defines several common widgets and properties that are suitable for many applications. You can add and remove widget properties to suit your specific needs. If you want to use custom editors with your QDataTable or QSqlForm, you must install your own QSqlPropertyMap for that table or form. Example: QSqlPropertyMap *myMap = new QSqlPropertyMap(); QSqlForm *myForm = new QSqlForm( this ); MyEditor myEditor( this ); // Set the QSqlForm's record buffer to the update buffer of // a pre-existing QSqlCursor called 'cur'. myForm->setRecord( cur->primeUpdate() ); // Install the customized map myMap->insert( "MyEditor", "content" ); myForm->installPropertyMap( myMap ); // myForm now owns myMap ... // Insert a field into the form that uses a myEditor to edit the // field 'somefield' myForm->insert( &myEditor, "somefield" ); // Update myEditor with the value from the mapped database field myForm->readFields(); ... // Let the user edit the form ... // Update the database fields with the values in the form myForm->writeFields(); ... You can also replace the global QSqlPropertyMap that is used by default. (Bear in mind that QSqlPropertyMap takes ownership of the new default map.) QSqlPropertyMap *myMap = new QSqlPropertyMap; myMap->insert( "MyEditor", "content" ); QSqlPropertyMap::installDefaultMap( myMap ); ... See also QDataTable, QSqlForm, QSqlEditorFactory, and Database Classes. MEMBER FUNCTION DOCUMENTATION
QSqlPropertyMap::QSqlPropertyMap () Constructs a QSqlPropertyMap. The default property mappings used by Qt widgets are: <center>.nf </center> QSqlPropertyMap::~QSqlPropertyMap () [virtual] Destroys the QSqlPropertyMap. Note that if the QSqlPropertyMap is installed with installPropertyMap() the object it was installed into, e.g. the QSqlForm, takes ownership and will delete the QSqlPropertyMap when necessary. QSqlPropertyMap * QSqlPropertyMap::defaultMap () [static] Returns the application global QSqlPropertyMap. void QSqlPropertyMap::insert ( const QString & classname, const QString & property ) Insert a new classname/property pair, which is used for custom SQL field editors. There must be a Q_PROPERTY clause in the classname class declaration for the property. Example: sql/overview/custom1/main.cpp. void QSqlPropertyMap::installDefaultMap ( QSqlPropertyMap * map ) [static] Replaces the global default property map with map. All QDataTable and QSqlForm instantiations will use this new map for inserting and extracting values to and from editors. QSqlPropertyMap takes ownership of &#92;a map, and destroys it when it is no longer needed. QVariant QSqlPropertyMap::property ( QWidget * widget ) Returns the mapped property of widget as a QVariant. void QSqlPropertyMap::remove ( const QString & classname ) Removes classname from the map. void QSqlPropertyMap::setProperty ( QWidget * widget, const QVariant & value ) [virtual] Sets the property of widget to value. SEE ALSO
http://doc.trolltech.com/qsqlpropertymap.html http://www.trolltech.com/faq/tech.html COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. AUTHOR
Generated automatically from the source code. BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qsqlpropertymap.3qt) and the Qt version (3.3.8). Trolltech AS 2 February 2007 QSqlPropertyMap(3qt)
All times are GMT -4. The time now is 03:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy