Skip to content
Execute a command for each line in a file
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

foreach-line -- execute a command for each line in a file

I often create lists of files and save them to text files, for later processing. Working on multiple computers with different shells and environments, I often stumble over different for loop syntaxes. foreach-line attempts to resolve this issue by behaving in a defined manner no matter what line ending is used -- as one would expect, one execution per line.

I know xargs does support this workflow in principle, but I always misremember the flags.


$ go install


$ foreach-line list-of-links.txt wget


  • Support arbitrary file name positions by a marker like {} (customisable via flag)


Feel free to contact me if you have any ideas where this might be going, open an issue, or a pull request!

You can’t perform that action at this time.