How do I join an array with an extra element in `bash`?

Suppose I have a bash for-loop

for name in *; do
    printf $(some stats about $name)
done

      

Now I would also like to print the same one stats

about the current folder, in a different word, something like

for name in (* and .); do   # NOT VALID BASH COMMAND
    printf $(some stats about $name)
done

      

My question is, what should I do for a "pseudo command" (* and .)

?

I know I can just do it printf $(some stats about .)

after the for loop, but I would like to know if there is a more general way to do this. (Just assume $(some stats about $name)

long, and I'd like to avoid defining another function if possible). Thank!

+3


source to share


1 answer


Try simply

for name in * . ; do
    printf $(some stats about $name)
done

      



to add an item to the list to loop through for

.

+3


source







All Articles