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

6 sec read

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

Last Updated On April 07, 2018

Leave a Reply

avatar
  Subscribe  
Notify of