Note that the behavior with the default FS=" " to skip and delimit using both blanks and newlines, used to be different in older Posix implementations, where blanks were used, but not newlines. mawk and gawk still support this older POSIX defined behavior, with special compatibility command line options.
compare:
to
Likewise for gawk with the --posix option.
Last edited by Scrutinizer; 02-02-2019 at 10:13 AM..
This User Gave Thanks to Scrutinizer For This Post:
I'm at wits end with this issue and my troubleshooting leads me to believe it is a problem with the file formatting of the array referenced by my script:
awk -F, '{if (NR==FNR) {a=$4","$3","$2}\
else {print a "," $0}}' WBTSassignments1.txt RNCalarms.tmp
On the WBTSassignments1.txt file... (2 Replies)
Hello, I am using awk to match text in a tab separated field and am able to do so when matching the exact word. My problem is that I would like to match any sequence of text in the tab-separated field without having to match it all. Any help will be appreciated. Please see the code below.
awk... (3 Replies)
i have a file like this
< '393200103052';'H3G';'20081204'
< '393200103059';'TIM';'20110111'
< '393200103061';'TIM';'20060206'
< '393200103064';'OPI';'20110623'
> '393200103052';'HKG';'20081204'
> '393200103056';'TIM';'20110111'
> '393200103088';'TIM';'20060206'
Now i have to generate a file... (9 Replies)
attempting the hangman program. This was an optional assignment from the professor. I have completed the logical coding, debugging now.
##I have an array $wordString that initializes to a string of dashes
##reflecting the number of letters in $theWord
##every time the user enters a (valid)... (5 Replies)
Hi All,
I got stuck up with shell script where i use awk. The scenario which i am working on is as below.
I have a file text.txt with contents
COL1 COL2 COL3 COL4
1 A 500 400
1 B 500 400
1 A 500 200
2 A 290 300
2 B 290 280
3 C 100 100
I could able to sum col 3 and col4 based on... (3 Replies)
here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb
cat dump.sql
INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Hi
Input:
{ committed = 782958592; init = 805306368; max = 1051394048; used = 63456712; }
Result:
A map (maybe Associative Array) where I can iterate through the key/value. Something like this:
for key in $map
do
echo key=$key value=$map
done
Sample output from the map:
... (2 Replies)
Is there a reliable way to deal with whitespace in array indicies?
I am trying to annotate fails in a database using a table of known fails.
In a begin block I have code like this:
# Read in Known Fail List
getline < "'"$failListFile"'"; getline < "'"$failListFile"'"; getline <... (6 Replies)
Hi,
I am trying to read an Oracle listener log file line by line and need to separate the lines into several fields. The field delimiter for the line happens to be an asterisk.
I have the script below to start with but when running it, the echo command is globbing it to include other... (13 Replies)
In the awk below I am trying to get the average of the sum of $7 if the string in $4 matches in the line below it. The --- in the desired out is not needed, it is just to illustrate the calculation. The awk executes and produces the current out. I am not sure why the middle line is skipped and the... (2 Replies)
Discussion started by: cmccabe
2 Replies
LEARN ABOUT DEBIAN
xml::quote
Quote(3pm) User Contributed Perl Documentation Quote(3pm)NAME
XML::Quote - XML quote/dequote functions
SYNOPSIS
use strict;
use XML::Quote qw(:all);
my $str=q{666 > 444 & "apple" < 'earth'};
print xml_quote($str),"
";
# 666 > 444 & "apple" < 'earth'
my $str2=q{666 > 444 & "apple" < 'earth'};
print xml_dequote($str2),"
";
# 666 > 444 & "apple" < 'earth'
my $str3=q{666 > 444 & "apple" < 'earth'};
print xml_quote_min($str3),"
";
# 666 > 444 & "apple" < 'earth'
DESCRIPTION
This module provides functions to quote/dequote strings in "xml"-way.
All functions are written in XS and are very fast; they correctly process utf8, tied, overloaded variables and all the rest of perl
"magic".
FUNCTIONS
$quoted = xml_quote($str);
This function replaces all occurences of symbols '&', '"', ''', '>', '<' to '&', '"', ''', '>', '<' respectively.
Returns quoted string or undef if $str is undef.
$dequoted = xml_dequote($str);
This function replaces all occurences of '&', '"', ''', '>', '<' to '&', '"', ''', '>', '<' respectively. All
other entities (for example ) will not be touched.
Returns dequoted string or undef if $str is undef.
$quoted = xml_quote_min($str);
This function replaces all occurences of symbols '&', '"', '<' to '&', '"', '<' respectively. Symbols ''' and '>' are not
replaced.
Returns quoted string or undef if $str is undef.
EXPORT
xml_quote(), xml_dequote() are exported as default.
PERFORMANCE
You can use t/benchmark.pl to test the perfomance. Here is the result on my P4 box.
Benchmark: timing 1000000 iterations of perl quote, xs quote...
perl quote: 108 wallclock secs (88.08 usr + 0.01 sys = 88.09 CPU) @ 11351.64/s (n=1000000)
xs quote: 20 wallclock secs (16.78 usr + 0.00 sys = 16.78 CPU) @ 59591.20/s (n=1000000)
Benchmark: timing 1000000 iterations of perl dequote, xs dequote...
perl dequote: 106 wallclock secs (85.22 usr + 0.09 sys = 85.31 CPU) @ 11721.54/s (n=1000000)
xs dequote: 19 wallclock secs (15.92 usr + 0.02 sys = 15.94 CPU) @ 62743.13/s (n=1000000)
AUTHOR
Sergey Skvortsov <skv@protey.ru>
SEE ALSO
http://www.w3.org/TR/REC-xml <http://www.w3.org/TR/REC-xml>, perlre
COPYRIGHT
Copyright 2003 Sergey Skvortsov <skv@protey.ru>. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2008-06-26 Quote(3pm)