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

No Comments
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.

Last Updated On April 07, 2018

Related Articles

No results found

Leave a Reply

avatar
  Subscribe  
Notify of
Menu
Copy link