Reputation: 1
In this if condition for shell script, i want print user full name + exist(if the file ..../pub_key.asc found)or not exist if the mentioned file not found.
for file in $FILES
do
if [ -f /home/$file/public_html/pub_key.asc ]; then
echo $(cat /home/$file/etc/passwd | head -n | cut -d: -f1) : Exists
else
echo $(cat /home/$file/etc/passwd | head -n | cut -d: -f1) : Not exists!
fi
done
But i get errors because there is something wrong with first echo in if..condition. Can someone show tell me what i did worng in the echo statement? and how to fix? appreciate your suggestions. :)
Upvotes: 0
Views: 339
Reputation: 447
You are probably getting an error due to head -n command
head -n has to be followed by a number, e.g head -n 1, or head -1
Upvotes: 2