i am using opensuse as a virtual machine on my laptop. this question is about code that i need to do for my homework.
I need to make a script with a variable that shows the amount of entries in a directory.
when i write the exact command in a bash script the output is diffrent from when i run it directly from the CLI
#! /bin/bash
clear
ENTRIES=$(ls /tmp | wc -l)
echo "the amount of entries is" "$ENTRIES"
When i run this script the output will be 53
but when i type the command "ls /tmp | wc -l" in the terminal/CLI i get 61
does anyone know how to solve/explain this?
I got confused and went to look online for answers but I could not find any that's why I am asking this question
thanks for the effort
Sorry for any spelling mistakes. I‘m from the Netherlands.
/tmp; the difference could simply be due to when you ran the command versus any differences between a script and the interactive prompt.alias ls='ls -a'? Aliases won't be set or expanded for your script.ls /home/janitself in both settings should help clear this up as well. If you don't understand the counts, look at what's actually being counted.)