rachuism rachuism - 7 months ago 15
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


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