How to loop through lines in a file using Bash

H

How Can We Help?

How to loop through lines in a file using Bash

for i in $(cat myFile.txt); do echo $i; done

The above code executes a for loop and then echo’s out each line in the file myFile.txt

About the author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

About Author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

Follow Me