Sponsored Content
Full Discussion: awk gsub multiple fields
Top Forums Shell Programming and Scripting awk gsub multiple fields Post 302723429 by pamu on Tuesday 30th of October 2012 06:18:19 AM
Old 10-30-2012
Quote:
Originally Posted by nakaedu
Code:
awk  -F ";"  -v OFS="";""  "function GSUB( F ) {gsub(/\./,\",\",$F); print} { GSUB( 6 ); GSUB( 7 ); GSUB( 8 ) } 1" s.final.gb2.csv  >s.final2.csv

But is not working
Is there any specific reasons for using " instead of '..?

try

Code:
awk  -F ";"  -v OFS=";"  'function GSUB(F) {gsub(/\./,",",$F)} {GSUB(6);GSUB(7);GSUB(8)}1' s.final.gb2.csv  >s.final2.csv

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK multiple fields separators

I need to print the second field of a file, taking spaces, tab and = as field separators. ; for 16-bit app support MAPI=1 CMC=1 CMCDLLNAME32=mapi32.dll CMCDLLNAME=mapi.dll MAPIX=1 MAPIXVER=1.0.0.1 OLEMessaging=1 asf=MPEGVideo asx=MPEGVideo ivf=MPEGVideo m3u=MPEGVideo (2 Replies)
Discussion started by: PamPam
2 Replies

2. Shell Programming and Scripting

Awk; gsub in fields 3 and 4

I want to transform a log file into input for a database. Here's the log file: Tue Aug 4 20:17:01 PDT 2009 Wireless users: 339 Daily Average: 48.4285 = Tue Aug 11 20:17:01 PDT 2009 Wireless users: 295 Daily Average: 42.1428 = Tue Aug 18 20:17:01 PDT 2009 Wireless users: 294 Daily... (6 Replies)
Discussion started by: Bubnoff
6 Replies

3. Shell Programming and Scripting

awk + gsub to search multiple input values & replace with located string + extra text

Hi all. I have the following command that is successfully searching for any one of the strings on all lines of a file and replacing it with the instructed value. cat inputFile | awk '{gsub(/aaa|bbb|ccc|ddd/,"1234")}1' > outputFile This does in fact replace any occurrence of aaa, bbb,... (2 Replies)
Discussion started by: dazhoop
2 Replies

4. UNIX for Dummies Questions & Answers

awk: multiple gsub in a script

%%%%% (1 Reply)
Discussion started by: lucasvs
1 Replies

5. Shell Programming and Scripting

Using multiple gsub() function under a loop in awk

Hi ALL, I want to replace string occurrence in my file "Config" using a external file named "Mapping" using awk. $cat Config ! Configuration file for RAVI ! Configuration file for RACHANA ! Configuration file for BALLU $cat Mapping ravi:ram rachana:shyam ballu:hameed The... (5 Replies)
Discussion started by: useless79
5 Replies

6. Shell Programming and Scripting

awk multiple fields separators

Can you please help me with this .... Input File share "FTPTransfer" "/v31_fs01/root/FTP-Transfer" umask=022 maxusr=4294967295 netbios=NJ09FIL530 share "Test" "/v31_fs01/root/Test" umask=022 maxusr=4294967295 netbios=NJ09FIL530 share "ENR California" "/v31_fs01/root/ENR California"... (14 Replies)
Discussion started by: greycells
14 Replies

7. Shell Programming and Scripting

Replace 0 with 1 in multiple fields with awk

Hello, I have the following input file: 1 3 3 2 3 3 4 0 4 0 5 4 5 2 2 0 5 3 4 0 6 0 3 2 I am trying to remove all zeroes in fields 2 and 4 and replace them with "1's" I tried the following, but it's not working awk -F"\t" '{ if (($2==0) || ($4==0) $2=1; $4=1; print $0 ) }' input ... (8 Replies)
Discussion started by: Rabu
8 Replies

8. UNIX for Beginners Questions & Answers

awk GSUB read field values from multiple text files

My program run without error. The problem I am having. The program isn't outputting field values with the column headers to file.txt. Each of the column headers in file.txt has no data. MEMSIZE SECOND SASFoundation Filename The output results in file.txt should show: ... (1 Reply)
Discussion started by: dellanicholson
1 Replies

9. Shell Programming and Scripting

Print multiple fields with awk

so its common knowledge one can print multiple fields with simple commands like this: echo 12 44 45 552 24 | awk '{print $1,$4,$3}' but suppose i want to avoid specifying the "$" symbol. is that possible? can something like this be done: echo 12 44 45 552 24 | awk '{print $(1,4,3)}' ... (9 Replies)
Discussion started by: SkySmart
9 Replies

10. Shell Programming and Scripting

awk gsub command to replace multiple spaces

Hi Forum. I'm trying to cleanup the following data elements (To remove any occurences of commas and any extra spaces) while preserving the <TAB> delimiter using awk gsub but I have not been successful. Original Data: 4365 monte des source rue,, ,<TAB>trevost<TAB>QC Desired Data:... (1 Reply)
Discussion started by: pchang
1 Replies
Font::TTF::Font(3pm)					User Contributed Perl Documentation				      Font::TTF::Font(3pm)

NAME
Font::TTF::Font - Memory representation of a font SYNOPSIS
Here is the regression test (you provide your own font). Run it once and then again on the output of the first run. There should be no differences between the outputs of the two runs. $f = Font::TTF::Font->open($ARGV[0]); # force a read of all the tables $f->tables_do(sub { $_[0]->read; }); # force read of all glyphs (use read_dat to use lots of memory!) # $f->{'loca'}->glyphs_do(sub { $_[0]->read; }); $f->{'loca'}->glyphs_do(sub { $_[0]->read_dat; }); # NB. no need to $g->update since $f->{'glyf'}->out will do it for us $f->out($ARGV[1]); $f->release; # clear up memory forcefully! DESCRIPTION
A Truetype font consists of a header containing a directory of tables which constitute the rest of the file. This class holds that header and directory and also creates objects of the appropriate type for each table within the font. Note that it does not read each table into memory, but creates a short reference which can be read using the form: $f->{$tablename}->read; Classes are included that support many of the different TrueType tables. For those for which no special code exists, the table type "table" is used, which defaults to Font::TTF::Table. The current tables which are supported are: table Font::TTF::Table - for unknown tables EBDT Font::TTF::EBDT EBLC Font::TTF::EBLC Feat Font::TTF::GrFeat GDEF Font::TTF::GDEF GPOS Font::TTF::GPOS GSUB Font::TTF::GSUB LTSH Font::TTF::LTSH OS/2 Font::TTF::OS_2 PCLT Font::TTF::PCLT Sill Font::TTF::Sill bsln Font::TTF::Bsln cmap Font::TTF::Cmap - see also Font::TTF::OldCmap cvt Font::TTF::Cvt_ fdsc Font::TTF::Fdsc feat Font::TTF::Feat fmtx Font::TTF::Fmtx fpgm Font::TTF::Fpgm glyf Font::TTF::Glyf - see also Font::TTF::Glyph hdmx Font::TTF::Hdmx head Font::TTF::Head hhea Font::TTF::Hhea hmtx Font::TTF::Hmtx kern Font::TTF::Kern - see alternative Font::TTF::AATKern loca Font::TTF::Loca maxp Font::TTF::Maxp mort Font::TTF::Mort - see also Font::TTF::OldMort name Font::TTF::Name post Font::TTF::Post prep Font::TTF::Prep prop Font::TTF::Prop vhea Font::TTF::Vhea vmtx Font::TTF::Vmtx DSIG FONT::TTF::DSIG Links are: Font::TTF::Table Font::TTF::EBDT Font::TTF::EBLC Font::TTF::GrFeat Font::TTF::GDEF Font::TTF::GPOS Font::TTF::GSUB Font::TTF::LTSH Font::TTF::OS_2 Font::TTF::PCLT Font::TTF::Sill Font::TTF::Bsln Font::TTF::Cmap Font::TTF::Cvt_ Font::TTF::Fdsc Font::TTF::Feat Font::TTF::Fmtx Font::TTF::Fpgm Font::TTF::Glyf Font::TTF::Hdmx Font::TTF::Head Font::TTF::Hhea Font::TTF::Hmtx Font::TTF::Kern Font::TTF::Loca Font::TTF::Maxp Font::TTF::Mort Font::TTF::Name Font::TTF::Post Font::TTF::Prep Font::TTF::Prop Font::TTF::Vhea Font::TTF::Vmtx Font::TTF::OldCmap Font::TTF::Glyph Font::TTF::AATKern Font::TTF::OldMort Font::TTF::DSIG INSTANCE VARIABLES
Instance variables begin with a space (and have lengths greater than the 4 characters which make up table names). nocsum This is used during output to disable the creation of the file checksum in the head table. For example, during DSIG table creation, this flag will be set to ensure that the file checksum is left at zero. noharmony If set, do not harmonize the script and lang trees of GPOS and GSUB tables. See Font::TTF::Ttopen for more info. fname (R) Contains the filename of the font which this object was read from. INFILE (P) The file handle which reflects the source file for this font. OFFSET (P) Contains the offset from the beginning of the read file of this particular font directory, thus providing support for TrueType Collections. METHODS
Font::TTF::Font->AddTable($tablename, $class) Adds the given class to be used when representing the given table name. It also 'requires' the class for you. Font::TTF::Font->Init For those people who like making fonts without reading them. This subroutine will require all the table code for the various table types for you. Not needed if using Font::TTF::Font::read before using a table. Font::TTF::Font->new(%props) Creates a new font object and initialises with the given properties. This is primarily for use when a TTF is embedded somewhere. Notice that the properties are automatically preceded by a space when inserted into the object. This is in order that fields do not clash with tables. Font::TTF::Font->open($fname) Reads the header and directory for the given font file and creates appropriate objects for each table in the font. $f->read Reads a Truetype font directory starting from the current location in the file. This has been separated from the "open" function to allow support for embedded TTFs for example in TTCs. Also reads the "head" and "maxp" tables immediately. $f->out($fname [, @tablelist]) Writes a TTF file consisting of the tables in tablelist. The list is checked to ensure that only tables that exist are output. (This means that you can't have non table information stored in the font object with key length of exactly 4) In many cases the user simply wants to output all the tables in alphabetical order. This can be done by not including a @tablelist, in which case the subroutine will output all the defined tables in the font in alphabetical order. Returns $f on success and undef on failure, including warnings. All output files must include the "head" table. $f->out_xml($filename [, @tables]) Outputs the font in XML format $f->XML_start($context, $tag, %attrs) Handles start messages from the XML parser. Of particular interest to us are <font> and <table>. $f->update Sends update to all the tables in the font and then resets all the isDirty flags on each table. The data structure in now consistent as a font (we hope). $f->dirty Dirties all the tables in the font $f->tables_do(&func [, tables]) Calls &func for each table in the font. Calls the table in alphabetical sort order as per the order in the directory: &func($table, $name); May optionally take a list of table names in which case func is called for each of them in the given order. $f->release Releases ALL of the memory used by the TTF font and all of its component objects. After calling this method, do NOT expect to have anything left in the "Font::TTF::Font" object. NOTE, that it is important that you call this method on any "Font::TTF::Font" object when you wish to destruct it and free up its memory. Internally, we track things in a structure that can result in circular references, and without calling '"release()"' these will not properly get cleaned up by Perl. Once you've called this method, though, don't expect to be able to do anything else with the "Font::TTF::Font" object; it'll have no internal state whatsoever. Developer note: As part of the brute-force cleanup done here, this method will throw a warning message whenever unexpected key values are found within the "Font::TTF::Font" object. This is done to help ensure that any unexpected and unfreed values are brought to your attention so that you can bug us to keep the module updated properly; otherwise the potential for memory leaks due to dangling circular references will exist. BUGS
Bugs abound aplenty I am sure. There is a lot of code here and plenty of scope. The parts of the code which haven't been implemented yet are: Post Version 4 format types are not supported yet. Cmap Format type 2 (MBCS) has not been implemented yet and therefore may cause somewhat spurious results for this table type. Kern Only type 0 & type 2 tables are supported (type 1 & type 3 yet to come). TTC The current Font::TTF::Font::out method does not support the writing of TrueType Collections. In addition there are weaknesses or features of this module library o There is very little (or no) error reporting. This means that if you have garbled data or garbled data structures, then you are liable to generate duff fonts. o The exposing of the internal data structures everywhere means that doing radical re-structuring is almost impossible. But it stop the code from becoming ridiculously large. Apart from these, I try to keep the code in a state of "no known bugs", which given the amount of testing this code has had, is not a guarantee of high quality, yet. For more details see the appropriate class files. AUTHOR
Martin Hosken Martin_Hosken@sil.org Copyright Martin Hosken 1998. No warranty or expression of effectiveness, least of all regarding anyone's safety, is implied in this software or documentation. Licensing The Perl TTF module is licensed under the Perl Artistic License. perl v5.10.1 2010-06-07 Font::TTF::Font(3pm)
All times are GMT -4. The time now is 06:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy