I'm concerned regarding what awk
shows as the record length. I'm checking some files for a specific record length - awk shows the result I wanted, but the file size shows that each record in the file is actually larger than what awk
says by 1 byte.
$ ls -l some_file.txt
-rw-r--r-- 1 foo bar 250614 Oct 20 08:49 some_file.txt
$ awk '{ print length }' some_file.txt | sort -u
458
$ echo "(250614%458)" | bc
88
$ echo "(250614%459)" | bc
0
Notice that the bc
result is wrong with a record length of 458
, but seems fine with a record length of 459
. Also, awk
+ sort
shows that all records have a record length of 458
. My educated guess is that awk
is not accounting for the End Of Line character, hence making a real record length of 459
. What do you think?
ps: awk
on AIX 5.3
awk
, is the output record separatorORS
not set to the newline character therefore it is classed as a seperator instead of a character? – geedoubleya Oct 20 '14 at 14:29ORS
in myawk
? – jimm-cl Oct 20 '14 at 14:55RS
) NOTORS
. – geedoubleya Oct 20 '14 at 15:03echo | awk '{print RS}'
). – geedoubleya Oct 20 '14 at 15:13RS
to something that does not exist in the file so it ignores the newline character and counts all the characters. e.g.awk 'BEGIN {RS=":"} {print length}'
some_file.txt – geedoubleya Oct 20 '14 at 15:20