当前位置: 动力学知识库 > 问答 > 编程问答 >

bash - get usernames from command last output

问题描述:

I need to get all users from file, containing information about all loggins within some time interval. (The delimiter is : )

So, I need to get all users from output of command last -f.

I tried to do this:

last -f file| cut -d ":" -f1

but in the output aren't just the usernames. It seems to me like some record take more than just one line and therefore it can't distinguish the records. I don't know.

Could you help me please? I would be grateful for any advice.

网友答案:

You could say:

last -f file | awk '{print $1}'

If you want to use cut, say:

last -f file| cut -d " " -f1
分享给朋友:
您可能感兴趣的文章:
随机阅读: