How to loop through the output of a Linux command in Bash

for fileName in $(ls)
do
	echo $fileName
done

or a one liner

for fileName in $(ls); do echo $fileName; done

Replace the ls command with any Linux command

Image Credits: Photo by Isis França on Unsplash.

More Similar Posts

No results found.

Menu