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.
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.