I have a doubt because I understand that:
exec 0</etc/passwd
IFS=:
while read in USUARIO
do
echo $USUARIO
done
output should be a list contining all system's users, instead of that I get the second row which is filled with x, when I want the first one; why?
Also, in this script you pass as argument a number and you see the list of user who have equal and more files than the value entered:
#!/bin/bash
if [[ ( $# -eq 1) && ( $1==[0-9][0-9]* )]]
then
echo "User with $1 files or more "
cut -d':' -f1 /etc/passwd | while IFS= read -r USUARIO
do
if [[ $( find / -user $USUARIO -print | wc -l ) -ge $1 ]]
then
echo $USUARIO
fi
done
exit 0
else
printf "Error: $0 int"
exit 1
fi
and it works ok, but why it doesn't works:
#!/bin/bash
if [[ ( $# -eq 1) && ( $1==[0-9][0-9]* )]]
then
LIST="Users with more or $1 files: "
cut -d':' -f1 /etc/passwd | while IFS= read -r USUARIO
do
if [[ $( find / -user $USUARIO -print | wc -l ) -ge $1 ]]
then
LIST="$LIST $USUARIO"
fi
done
echo $LIST
exit 0
else
printf "Error $0 int"
exit 1
fi
Its outputs is the raw string without appending user's names why?
read in USUARIO
assigns the first field to a variable namedin
– steeldriver Oct 29 '16 at 17:43