Do i miss counter or what

hello
this script should show all users and space they used without problem :

ls /home >> /root/users.txt
cat /root/users.txt | while read line; do
space=`du -s /home/$line`
echo "$line space is $space"
shift
done

but when i remove pipe ,script run without any output:

ls /home >> /root/users.txt
mama=`cat /root/users.txt`
while read $mama; do
space=`du -s /home/$mama`
echo "$mama space is $space"
done

try this way you will come to know, in second code you are reading nothing so no o/p

while read line; do
     echo $line
done < "Your_Input_File"
mama=`cat /root/users.txt`
while read $mama; do

var mama execute cat and read txt file so the input of mama is users.txt
then while command read this file,
can you explain me why nothing so no o/p ?

Have a compare:

users=$(ls /home --hide=lost+found)	# This sets all content but 'lost+found' into the list: users
for usr in $users;do			# For each entry (named: usr) in list 'users', do ....
	space=$(du -hsx /home/$usr)	# higly recomend 'x' if you mount other filesystems inside user dirs, 'h' makes it more 'readable'
	echo "$usr space is $space"
done
ls /home --hide=lost+found > /root/users.txt	# Write all content but 'lost+found' into the file: /root/users.txt, using 
while read mama; do				# For each line (named: mama), do ....
	space=`du -s /home/$mama`
	echo "$mama space is $space"
done < /root/users.txt				# while reading from file

hth

Imagine that /root/users.txt contains:

andy
bob
celia
denise

After executing the command mama=`cat /root/users.txt` , the command:

while read $mama; do
space=`du -s /home/$mama`
echo "$mama space is $space"
done

will be expanded by the shell to:

while read andy bob celia denise; do
space=`du -s /home/andy
bob
celia
denise`
echo "andy
bob
celia
denise space is $space"
done

which will read lines of text from standard input and assign the first word found on each line to the variable andy , the second word found on each line to the variable bob , the third word found on each line to the variable celia , and the remaining words on each line to the variable denise . I assume that rather than producing no output, it is actually sitting there waiting for you to type in a line in response to the read command.

I hope this explains what you were doing wrong.

Others have already shown you how to fix it.