LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-19-2010, 04:00 PM   #1
ws.mahmood
LQ Newbie
 
Registered: Nov 2010
Posts: 3

Rep: Reputation: 0
Post For loop


what is for loops in redhat linux ??????????????
 
Old 11-19-2010, 04:36 PM   #2
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
Welcome to LQ.

Not sure I understand your question.

Usually, a "for loop" is a set of instructions wich are repeated, based on a variable being incremented or decremented from one value to one another, this variable being or not used in this set of instructions. It's a feature of programming languages, not of operating systems, as far as I know.

Last edited by Didier Spaier; 11-19-2010 at 04:45 PM.
 
1 members found this post helpful.
Old 11-20-2010, 04:11 AM   #3
divyashree
Senior Member
 
Registered: Apr 2007
Location: Bangalore, India
Distribution: RHEL,SuSE,CentOS,Fedora,Ubuntu
Posts: 1,386

Rep: Reputation: 135Reputation: 135
Quote:
Originally Posted by ws.mahmood View Post
what is for loops in redhat linux ??????????????

Welcome to LQ. For loops is used in scripting or programming in redhat linux which repeteadly do something as stated upto certain times depending on the condition.
 
1 members found this post helpful.
Old 11-27-2010, 04:25 AM   #4
ws.mahmood
LQ Newbie
 
Registered: Nov 2010
Posts: 3

Original Poster
Rep: Reputation: 0
thanks a lot
 
Old 11-27-2010, 04:15 PM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Red Hat Linux is irrelavent here.

A "For Loop" is a feature of many popular programming languages, it usually can be one of two flavors depending on the language:

The first style has an initializer, a test to see if it should keep going, and a place to increment the counting variable. From the C language:

Code:
// this example counts from 1 to 10

int i;
for (i = 1; i <= 10; i = i + 1) {
    printf("%d\n", i);
}
In other languages, the for loop iterates over values in a list. For example in the Python language:

Code:
values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
for value in values:
    print value
The bash shell (this is probably what you meant by "Red Hat Linux") also uses this style of for loop:

Code:
# list files in current directory

for file in *
do
    echo "$file"
done

Last edited by MTK358; 11-27-2010 at 04:18 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to loop over text file lines within bash script for loop? johnpaulodonnell Linux - Newbie 9 07-28-2015 03:49 PM
for loop or while loop to read the fields of a file.. visitnag Linux - Newbie 10 09-02-2010 08:47 PM
bash loop within a loop for mysql ops br8kwall Programming 10 04-30-2008 03:50 AM
converting shell while loop to for loop farkus888 Programming 8 09-12-2007 02:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration