bash

Applying a command to each line in a file with xargs -L1

Let’s say you have a text file which you wish to use an input to some command-line tool. Specifically, the goal is to apply the same command to each line in the file. This short post showcases how this can be done in a Unix shell (such as Bash) using a combination of cat, xargs and piping. As a motivating example, consider a file repos.txt containing URLs of several Github repositories, and our goal is to clone each of the repositiries.