Sponsored Content
Full Discussion: Problem with AWK and OFS
Top Forums UNIX for Dummies Questions & Answers Problem with AWK and OFS Post 302566569 by bartus11 on Thursday 20th of October 2011 03:41:32 PM
Old 10-20-2011
"END" is a clause that is executed after whole file is processed. All the variables that were created during processing of the file are accessible there, so when AWK reads last line into $0, it is still there when executing "END" Smilie
This User Gave Thanks to bartus11 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

OFS in awk

Hi, I have these out put field seperator changed to "|" in my awk command, but it didn't give me the result. Can someone help me find out why? ======================================= /bin/awk 'BEGIN { OFS="|" } { print $0 }' list.tmp.$$ > listtmp.$$ =======================================... (1 Reply)
Discussion started by: whatsfordinner
1 Replies

2. Shell Programming and Scripting

OFS in awk.

OFS is inbuild command in awk. I have a file file.txt abc : def : ghi jkl : mno: pqr stu : vwx :yzz code i used: awk -F ":" 'BEGIN {OFS="|"} {print $1,$2}' file.txt output: abc def jkl mno stu vwx but as i have used OFS="|" and i am expecting output as: abc | def jkl... (4 Replies)
Discussion started by: salil2012
4 Replies

3. Shell Programming and Scripting

AWK - OFS

Hi All, I have a comma seperated delimited file with 10 columns. I need to convert it into TAB seperated delimited file. awk -F"," '{print $1"\t"$2"\t"$3"\t"$4"\t"$5"\t"$6"\t"$7"\t"$8"\t"$9"\t"$10}' a.txt >> b.txt how to use OFS to get the same output. I have tried by googling, but it... (5 Replies)
Discussion started by: Amit.Sagpariya
5 Replies

4. Shell Programming and Scripting

Parsing XML in awk : OFS does not work as expected

Hi, I am trying to parse regular XML file where I have to reduce number of decimal points in some xml elements. I am using following AWK command to achive that : #!/bin/ksh EDITCMD='BEGIN { FS = ""; OFS=FS } { if ( $3 ~ "*\\.*" && length(substr($3,1+index($3,"."))) == 15 ) {... (4 Replies)
Discussion started by: martin.franek
4 Replies

5. Shell Programming and Scripting

Awk OFS issues

Hi Im trying to tidy up the output of a who command when it writes to a log, everything I've tried doesnt seem to work though, any help would be massively appreciated. Im using the awk command to set the OFS as tab. #!/bin/bash who >> /export/home/tjmoore/logusers awk -F 'BEGIN... (3 Replies)
Discussion started by: 02JayJay02
3 Replies

6. Shell Programming and Scripting

Awk OFS issues

Hi, Could anyone tell me what Im doing wrong here any help will be much appreciated #!/bin/bash ls -ltr /export/home/tjmoore > /export/home/tjmoore/log100 awk -F " " /export/home/tjmoore/log100 'BEGIN {OFS="\t";} {print $1,$2,$3,$4,$5, $6,$7,$8,$9;}' > /export/home/tjmoore/log1001 I... (9 Replies)
Discussion started by: 02JayJay02
9 Replies

7. UNIX for Dummies Questions & Answers

OFS in awk

Hello, I have an issue with adding commas as delimiters in this scenario: cat xtr3.rpl|head -5|awk 'BEGIN {OFS=","} {print $1,$2,$3,$4}' Produces this output: 00530083,0000000471,000000000000.00,000000000000.00 00530085,0000000471,000000000000.00,000000000000.00... (10 Replies)
Discussion started by: MIA651
10 Replies

8. Shell Programming and Scripting

OFS print awk

file: sasa|asasa|asasa|asas erer|Erer|rere|ererer Output needed : sasa:asasa:asasa:asas erer:Erer:rere:ererer Im getting output, when i use the $1,$2. awk -F'|' 'BEGIN{OFS=":";} {print $1,$2; }' file Output : sasa:asasa erer:Erer But when i need the whole column, i... (5 Replies)
Discussion started by: Ramesh M
5 Replies

9. Shell Programming and Scripting

OFS does not apply to few records in awk

Hi , I am having a problem with my awk oneliner , which for some reason leaves the first two records Input File $ cat file1 A1:B1:C1:NoLimit M1:M2:M3:Limit A2:B2:C2,C3,C4,C5 A3:B3:C3,C4,C5,C6,C7Desired output A1,B1,C1,NoLimit M1,M2,M3,Limit A2,B2,C2 ,,,C3 ,,,C4 ,,,C5 A3,B3,C3... (5 Replies)
Discussion started by: chidori
5 Replies

10. Shell Programming and Scripting

awk - OFS printing duplicate. Why?

Why the following code printing duplicate records? bash-4.1$ cat rm1 c1 c2 c3 l1 2 3 4 l2 2 3 2 bash-4.1$ awk '{print $0} OFS = "\n"' rm1 c1 c2 c3 c1 c2 c3 l1 2 3 4 l1 2 3... (4 Replies)
Discussion started by: quincyjones
4 Replies
Config::IniHash(3pm)					User Contributed Perl Documentation				      Config::IniHash(3pm)

NAME
Config::IniHash - Perl extension for reading and writing INI files VERSION
Version 3.00.05 SYNOPSIS
use Config::IniHash; $Config = ReadINI 'c:somefile.ini'; DESCRIPTION
This module reads and writes INI files. Functions ReadINI $hashreference = ReadINI ($filename, %options) $hashreference = ReadINI ($data, %options) $hashreference = ReadINI (@data, %options) $hashreference = ReadINI ($filehandle, %options) The returned hash contains a reference to a hash for each section of the INI. [section] name=value leads to $hash->{section}->{name} = value; The available options are: heredoc - controls whether the module supports the heredoc syntax : name=<<END the many lines long value END othername=value 0 : heredocs are ignored, $data->{section}{name} will be '<<END' 1 : heredocs are supported, $data->{section}{name} will be "the many lines long value" The Perl-lie extensions of name=<<"END" and <<'END' are not supported! 'Perl' : heredocs are supported, $data->{section}{name} will be "the many lines long value" The Perl-lie extensions of name=<<"END" and <<'END' are supported. The <<'END' never interpolates %variables%, the "END" always interpolates variables, unlike in other values, the %variables% that are not defined do not stay in the string! Default: 0 = OFF systemvars - controls whether the (system) variables enclosed in %% are interpolated and optionaly contains the values in a hash ref. name=%USERNAME% leads to $data->{section}->{name} = "Jenda" systemvars = 1 - yes, take values from %ENV systemvars = \%hash - yes, take values from %hash systemvars = 0 - no case - controls whether the created hash is case insensitive. The possible values are sensitive - the hash will be case sensitive tolower - the hash will be case sensitive, all keys are made lowercase toupper - the hash will be case sensitive, all keys are made uppercase preserve - the hash will be case insensitive, the case is preserved (tied) lower - the hash will be case insensitive, all keys are made lowercase (tied) upper - the hash will be case insensitive, all keys are made uppercase (tied) withdefaults - controls whether the created section hashes support defaults. See Hash::WithDefaults. class - allows you to specify the class into which to tie the created hashes. This option overwrites the "case" and "withdefaults" options! You may for example use class => 'Tie::IxHash', to store the sections in hashes that remember the insertion order. sectionorder - if set to a true value then created hash will contain $config->{'__SECTIONS__'} = [ 'the', 'names', 'of', 'the', 'sections', 'in', 'the', 'order', 'they', 'were', 'specified', 'in', 'the', 'INI file']; - if set to an array ref, then the list will be stored in that array, and no $config->{'__SECTIONS__'} is created. The case of the section names stored in this array is controled by the "case" option even in case you specify the "class". allowmultiple - if set to a true scalar value then multiple items with the same names in a section do not overwrite each other, but result in an array of the values. - if set to a hash of hashes (or hash of arrays or hash of comma separated item names) specifies what items in what sections will end up as hashes containing the list of values. All the specified items will be arrays, even if there is just a single value. To affect the items in all sections use section name '*'. By default false. forValue - allows you to install a callback that will be called for each value as soon as it is read but before it is stored in the hash. The function is called like this: $value = $forValue->($name, $value, $sectionname, $INIhashref); If the callback returns an undef, the value will not be stored. comment - regular expression used to identify comments or a string containing the list of characters starting a comment. Each line is tested against the regexp is ignored if matches. If you specify a string a regexp like this will be created: qr/^s*[the_list]/ The default is qr/^s*[#;] layer - the IO layer(s) to use when opening the file. See perldoc "perlopen". If the file is in UTF8 and starts with a BOM it will be automaticaly opened in UTF8 mode and the BOM will be stripped. If it doesn't start with the BOM you have to specify the utf8 layer! You may also set the defaults for the options by modifying the $Config::IniHash::optionname variables. These default settings will be used if you do not specify the option in the ReadINI() or ReadSection() call. AddDefaults AddDefaults( $config, 'normal section name', 'default section name'); AddDefaults( $config, 'normal section name', \%defaults); This subroutine adds a some default values into a section. The values are NOT copied into the section, but rather the section knows to look up the missing options in the default section or hash. Eg. if (exists $config->{':default'}) { foreach my $section (keys %$config) { next if $section =~ /^:/; AddDefaults( $config, $section, ':default'); } } ReadSection $hashreference = ReadSection ($string) This function parses a string as if it was a section of an INI file and creates a hash with the values. It accepts the same options as ReadINI. WriteINI WriteINI ($filename, $hashreference) Writes the hash of hashes to a file. PrintINI The same as WriteINI(). AUTHOR
Jan Krynicky <Jenda@Krynicky.cz> http://Jenda.Krynicky.cz COPYRIGHT
Copyright (c) 2002-2005 Jan Krynicky <Jenda@Krynicky.cz>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2009-06-08 Config::IniHash(3pm)
All times are GMT -4. The time now is 05:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy