rachuism rachuism - 1 year ago 56
Linux Question

Why do I obtain blank response when listing linux users?

I'm trying to list all the users of my system with "cut" approach but I obtain nothing, any idea?


cat /etc/passwd | cut -d":" -f 1 > user

echo $user

Answer Source

As it's already mentioned in the comment above the problem is that you redirect your output to the file named user.

So, possible solutions are:

1) Check the user file's content.

2) Adjust your command to write it's output to the user variable:

user=`cat /etc/passwd | cut -d":" -f 1`
echo $user
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download