Commit all modified files to Git
Following these steps will do the work.
- Use
git status
to check the file status. - Use
grep
to search for themodified
keyword. - Extract the second column by using
cut
with the delimiter:
. - Remove surplus white spaces in front of the data field by using
sed
. - Connect the above commands in sequence via pipes.
- Quote the command list using ``, the result of which will be passed as the argument of
git add
.
The train of commands looks like this.
git add `git status | grep modified | cut -d ":" -f 2 | sed -e 's/^\s*//'`
Similarly, this method can be adapted for committing files in other status.