Click to See Complete Forum and Search --> : What is the delimeter in 'who's output???


noyzy
08-12-2007, 07:49 PM
Hi all,
I am still very new to linux but I have just come across a hurdle that I can not get past.

I am currently trying to format the output of 'who'.

I want to display usernames and IP adds, sort them by username and not show duplicates.

From what I have learnt I thought the following command would have worked:

who | cut -f 1,4 | sort -n -k1,1 | uniq

Obviously it doesn't though.

I have discovered that my problem lies within the delimeter not being a TAB.
(I discovered this when sending the output of who to a file).
Therefore there is just a heap of whitespaces breaking up the columns

So my question is:
Is there a way of using the -d in cut to use "whitespaces"?
I tried -d ' '
This just uses every ' ' though and gives me a column for every space. I was just wondering if there was a method I can use to tell it to eliminate all spaces and replace them with 1 whitespace or just disregard whitespaces in the first place.

Thanks in advance.

xrx
08-13-2007, 07:26 AM
You can replace "cut -f 1,5" with "awk '{print $1, $5}'". BTW: is there any particular reason you're using those arguments to "sort"?

noyzy
08-28-2007, 09:46 PM
thanks xrx
Sorry I have taken so long to reply I have been away on holidays
The reason I was using that way to sort is because that was all I had been taught at the time.