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.

Cancelling bad stuff in Git

In this post I am going to provide some examples of Git usage that may come in handy in case of unsuccessful previous actions during staging, committing, and merging. Let’s say you have staged some files to be further committed with git add and then change your mind. To unstage all or some files, invoke the git reset command (which is in a way an inverse of git add). A scenario for all changed files: