I currently use the following command to extract the 4th and 9th fields in our Syslog file.
I want to also include all fields in the actual messages starting with the 10th field.
I could do for example; tail messages|awk '{print $4 " " " " $9, $10, $11, $12, $13}'
In the above command, there are many more fields after the 13th field, but rather than inputting all fields, for which I have no idea how many fields there could be. I would rather use an expression (if there is one) that would simply include all fields from field 9 onwards to the end of the message.
Just written a great little script that analyses a flat ASCII CSV file and reports for any discrepancies with field counts per record etc.
Works fine on all the flat files except one, which has 113 fields per line. AWK can only seemingly cope with up to 99 fields.
Is there any way around... (2 Replies)
I'm working on formatting some attendance data to meet a vendors requirements to upload to their system. With some help on the forums here, I have the data close. But they've since changed what they want.
The vendor wants me to submit three fields to them. Field 1 is the studentid field,... (4 Replies)
I have file that I need to remove the duplicates. The problem is, I need to only keep the one which has a unique 3rd field. Here is a sample file:
xxx.xxx:x:CISCO1.CLEVE61W:ERIE.NET:x:x:x:x:
xxx.xxx:x:CISCO2.CLEVE62W:OHIO.NET:x:x:x:x:
xxx.xxx:x:CISCO2.CLEVE62W:NORTH.NET:x:x:x:x:... (1 Reply)
I feel like a real leech now, 3 questions in 3 days, but hopefully when I get my head around all of this I can contribute back to this community!
Anyway, so a couple of you guys have gotten me onto AWK and I've been researching it a little over the last couple of hours, now I'm somewhat sure I... (2 Replies)
Hi,
Could someone please let me know me how i can use an awk command to print the No. of fields of each file present in a Directory?Suppose the Directory has 5 text files in which the first record in each file contains fields separated by a '|'. I need to use a awk command to display the No... (8 Replies)
Hi All,
I am looking for an awk script to do the following
Join the fields together only if the first 4 fields are same.
Can it be done with join function in awk??
a,b,c,d,8,,,
a,b,c,d,,7,,
a,b,c,d,,,9,
a,b,p,e,8,,,
a.b,p,e,,9,,
a,b,p,z,,,,9
a,b,p,z,,8,,
desired output:
... (1 Reply)
Hi experts,
I need to print the first field first then last two fields should come next and then i need to print rest of the fields.
Input :
a1,abc,jsd,fhf,fkk,b1,b2
a2,acb,dfg,ghj,b3,c4
a3,djf,wdjg,fkg,dff,ggk,d4,d5
Expected output:
a1,b1,b2,abc,jsd,fhf,fkk... (6 Replies)
I'm trying to compare 2 files for differences in a selct number of fields. When differnces are found it will write the whole record of the second file including appending '|C' out to a delta file. Each record will have 20 fields, but only want to do comparison of 1st 15 fields. The 1st field of... (7 Replies)
Hi
I have a file as below
<field1> <field2> <field3> ... <field_num1> <field_num2>
Trying to sort based on difference of <field_num1> and <field_num2> in desceding order and print all fields.
I tried this and it doesn't sort on the difference field .. Appreciate your help.
cat... (9 Replies)
Discussion started by: newstart
9 Replies
LEARN ABOUT OSX
i18n::collate
I18N::Collate(3pm) Perl Programmers Reference Guide I18N::Collate(3pm)NAME
I18N::Collate - compare 8-bit scalar data according to the current locale
SYNOPSIS
use I18N::Collate;
setlocale(LC_COLLATE, 'locale-of-your-choice');
$s1 = I18N::Collate->new("scalar_data_1");
$s2 = I18N::Collate->new("scalar_data_2");
DESCRIPTION
***
WARNING: starting from the Perl version 5.003_06
the I18N::Collate interface for comparing 8-bit scalar data
according to the current locale
HAS BEEN DEPRECATED
That is, please do not use it anymore for any new applications
and please migrate the old applications away from it because its
functionality was integrated into the Perl core language in the
release 5.003_06.
See the perllocale manual page for further information.
***
This module provides you with objects that will collate according to your national character set, provided that the POSIX setlocale()
function is supported on your system.
You can compare $s1 and $s2 above with
$s1 le $s2
to extract the data itself, you'll need a dereference: $$s1
This module uses POSIX::setlocale(). The basic collation conversion is done by strxfrm() which terminates at NUL characters being a decent
C routine. collate_xfrm() handles embedded NUL characters gracefully.
The available locales depend on your operating system; try whether "locale -a" shows them or man pages for "locale" or "nlsinfo" or the
direct approach "ls /usr/lib/nls/loc" or "ls /usr/lib/nls" or "ls /usr/lib/locale". Not all the locales that your vendor supports are
necessarily installed: please consult your operating system's documentation and possibly your local system administration. The locale
names are probably something like "xx_XX.(ISO)?8859-N" or "xx_XX.(ISO)?8859N", for example "fr_CH.ISO8859-1" is the Swiss (CH) variant of
French (fr), ISO Latin(8859) 1 (-1) which is the Western European character set.
perl v5.16.2 2012-10-11 I18N::Collate(3pm)