From 93196c41e4a4d1e025e92c5463082f90f4738941 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 13 Jun 2018 13:59:16 +1000 Subject: [PATCH] docs: update --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 018d480..220c780 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ scripts and not full blown utilities. * [Get the first N lines of a file.](#get-the-first-n-lines-of-a-file) * [Get the last N lines of a file.](#get-the-last-n-lines-of-a-file) * [Get the number of lines in a file.](#get-the-number-of-lines-in-a-file) + * [Iterate over files.](#iterate-over-files) * [Create an empty file.](#create-an-empty-file) * [Strings](#strings) * [Trim white-space from string.](#trim-white-space-from-string) @@ -117,6 +118,22 @@ lines() { } ``` +### Iterate over files. + +Don’t use `ls`. + +```sh +# Greedy example. +for file in *; do + echo "$file" +done + +# PNG files in dir. +for file in ~/Pictures/*.png; do + echo "$file" +done +``` + ### Create an empty file. Alternative to `touch`.