Hi, i am still learning i want to make a simple shell script.
I wish to make a function that will receive 2 arguments (two dates) and will return
all users who logged in during that period, how many times and how long were
they logged in.

I wish to call my function this way: ./functionName 29/05 30/05

This would print out all users that were logged in during that period
how many times did they login and how long were they logged in.

Result would be maybe like: username 5x 0 days 12:43

How can i go about this, thanks in advance.

I have tried opening a notepad and writing something but i just
get confused on every step.

I am used to writing functions they way they are in C, Python, Java, PHP, Ruby
but here it seems its all sick and twisted.

Why not do the work in a language with which you are already comfortable? I have a dozen utilities in my $HOME/bin directory (which is early in my PATH) written in Python (and several more written in bash, and a couple compiled from C and ...)

For your task, I'd use Python, with [thread=257449]this small class by Gribouillis[/thread] to collect the output of last and look through the lines for the data you want, aggregating per user. (I would use Python, but you might prefer something else)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.