Computer Hope

Other Pages

Home
Site map
Computer help

Dictionary
News
Q&A
What's new

Tools

E-mail this page
Print Preview
Edit this page



 

Linux / Unix for, foreach and repeat

Quick links

About for, foreach and repeat
Syntax
Examples
Related commands
Linux / Unix main page

About for, foreach and repeat

Shell built-in functions to repeatedly execute action(s) for a selected number of times.

Syntax

for word [ in wordlist ... ] ; do actions ; done

foreach word ( wordlist )

[ ... ]

end

repeat count command

Examples

for file in *.txt ; do wc -l $file ; done - In ksh (Korn Shell) would do a word count of the files *.txt until done and would return results similar to the following:

5 myfile.txt
2 myfile2.txt
14 newfile.txt

Related commands

break
csh
ksh
sh

Index

Category:
Linux / Unix

Companies:
Click here

Related Pages:

Resolved

Were you able to locate the answer to your questions?

Home - Computer help - Contact - Dictionary - Links
Link to Computer Hope - Bookmark Computer Hope