Find knowledge base article(s) by searching for keywords in the title e.g. type linux in the search box below
Find knowledge base article(s) by browsing the subject categories of articles
Technology quick references, cheatsheets, user manuals etc.
Shop Online through ShopifyLite
Tutorials on various IT applications.
Search Title    (UL:0 |SS:f)

Software >> OS >> Unix >> Shell >> Commands >> for >> Examples of how to use for

(1)   Process files that match a wildcard

e.g. count the number of lines for each file that starts with q

# for f in `ls -1 q*`;do wc -l $f;done;

or

# for f in q*; do wc -l $f;done;

 

(2)   Run some command using a loop counter.  In this case for every count, we run echo $i and then sleep for 5 seconds.

# for i in {1..10};do echo $i;sleep 5;done;

[ © 2008-2021 myfaqbase.com - A property of WPDC Consulting ]