BASH Daily — Just An Alternative To Listing Files In A Directory
1 min readMar 28, 2019
There are many ways to do the same things in BASH. For example, there is an alternative to `ls` (https://linux.die.net/man/1/ls):
for file in *; do echo ${file}; done
This is practical if your system runs out of memory (e.g.: insufficient memory error).
It can also be useful if you want to do something with each file in a directory.
Here is an example:
for file in * ; \
do cp ${file} ${file.bak}; \
done
This an example where you are creating a copy of each file in a directory.