03-27-2017
That little script is taking advantage of some of awk's idiosyncrasies / default behaviour. It creates a 24 element array B by splitting the given string using the (default if ommitted: scriptwide) field separator (here: set to ","). In the print statement, the index is calculated by interpreting $2's (timestamp) contents up to the first non-digit char (":") as a number (default behaviour), and adding 1, mapping e.g. 00:xx:xx to index 1.
7 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi All,
I am new to unix programming. I am trying for a requirement and the requirement goes like this.....
I have a test folder. Which tracks log files. After certain time, the log file is getting overwritten by another file (randomly as the time interval is not periodic). I need to preserve... (2 Replies)
Discussion started by: mailsara
2 Replies
2. Programming
I need to return all records in a file starting with
a row that says
TABLE: <tabl name>
lists of hexadecimal records
TABLE: <some table>
TABLe is a key word in the file. I know the name of the table I want to start with. I do not know the name of the table that I will end with. I just... (4 Replies)
Discussion started by: guessingo
4 Replies
3. Shell Programming and Scripting
Hi Friends,
I have the following logfile. Currently time in india is 07/31/2014 12:33:34 and i have the following content in logfile. I want to display only those entries which contain string 'Exception' within last 3 hours. In this case, it would be the last line only
I can get the... (12 Replies)
Discussion started by: srkmish
12 Replies
4. Shell Programming and Scripting
Hello ,
I am working on AIX. I have to convert Unix timestamp to normal timestamp. Below is the file. The Unix timestamp will always be preceded by
EFFECTIVE_TIME as first field as shown and there could be multiple EFFECTIVE_TIME in the file : 3.txt
Contents of... (6 Replies)
Discussion started by: rahul2662
6 Replies
5. IP Networking
Hi All,
I'm a bit confused about assigning IP address from IP Ranges.
I am using this scenario below to understand.
Scenario
Adatum.com an international IT solutions company, is launching 12 new branches in a new country where they currently have no existing branches. The sWin CIO has asked... (3 Replies)
Discussion started by: TryllZ
3 Replies
6. Homework & Coursework Questions
THIS IS A SAMPLE PRACTICAL EXAM QUESTION, COMPLETE FILE HAS BEEN ATTACHED AS WELL.
Hi All,
I'm a bit confused about assigning IP address from IP Ranges.
I am using this scenario below to understand.
Scenario
Adatum.com an international IT solutions company, is launching 12 new branches in a... (10 Replies)
Discussion started by: TryllZ
10 Replies
7. Shell Programming and Scripting
So basically I have a log file and each line in this log file starts with a timestamp:
MON DD HH:MM:SS
SEP 15 07:30:01
I need to grep all the lines between last hour timestamp and current timestamp. Then these lines will be moved to a tmp file from which I will grep for particular strings. ... (1 Reply)
Discussion started by: nms
1 Replies
LEARN ABOUT MOJAVE
arybase5.18
arybase(3pm) Perl Programmers Reference Guide arybase(3pm)
NAME
arybase - Set indexing base via $[
SYNOPSIS
$[ = 1;
@a = qw(Sun Mon Tue Wed Thu Fri Sat);
print $a[3], "
"; # prints Tue
DESCRIPTION
This module implements Perl's $[ variable. You should not use it directly.
Assigning to $[ has the compile-time effect of making the assigned value, converted to an integer, the index of the first element in an
array and the first character in a substring, within the enclosing lexical scope.
It can be written with or without "local":
$[ = 1;
local $[ = 1;
It only works if the assignment can be detected at compile time and the value assigned is constant.
It affects the following operations:
$array[$element]
@array[@slice]
$#array
(list())[$slice]
splice @array, $index, ...
each @array
keys @array
index $string, $substring # return value is affected
pos $string
substr $string, $offset, ...
As with the default base of 0, negative bases count from the end of the array or string, starting with -1. If $[ is a positive integer,
indices from "$[-1" to 0 also count from the end. If $[ is negative (why would you do that, though?), indices from $[ to 0 count from the
beginning of the string, but indices below $[ count from the end of the string as though the base were 0.
Prior to Perl 5.16, indices from 0 to "$[-1" inclusive, for positive values of $[, behaved differently for different operations; negative
indices equal to or greater than a negative $[ likewise behaved inconsistently.
HISTORY
Before Perl 5, $[ was a global variable that affected all array indices and string offsets.
Starting with Perl 5, it became a file-scoped compile-time directive, which could be made lexically-scoped with "local". "File-scoped"
means that the $[ assignment could leak out of the block in which occurred:
{
$[ = 1;
# ... array base is 1 here ...
}
# ... still 1, but not in other files ...
In Perl 5.10, it became strictly lexical. The file-scoped behaviour was removed (perhaps inadvertently, but what's done is done).
In Perl 5.16, the implementation was moved into this module, and out of the Perl core. The erratic behaviour that occurred with indices
between -1 and $[ was made consistent between operations, and, for negative bases, indices from $[ to -1 inclusive were made consistent
between operations.
BUGS
Error messages that mention array indices use the 0-based index.
"keys $arrayref" and "each $arrayref" do not respect the current value of $[.
SEE ALSO
"$[" in perlvar, Array::Base and String::Base.
perl v5.18.2 2014-01-06 arybase(3pm)