Sponsored Content
Full Discussion: Help with While Loops
Top Forums UNIX for Dummies Questions & Answers Help with While Loops Post 302166840 by agn on Wednesday 13th of February 2008 01:04:16 AM
Old 02-13-2008
Can be done in many ways

One way:
Code:
cat list | while read line; do echo $line; done

Another way:
Code:
while read line; do echo $line; done < list

Yet another way:
Code:
exec < list

while read line
do
    echo $line
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

loops?

hello....very new user to unix...and i have a question..i am not sure if there is such a thing For example...the user is asked if he likes Bananas....if he says yes.... echo You like Bananas $name at the end of the script it echos all that the user has entered so they can read it.... but... (1 Reply)
Discussion started by: jonas27
1 Replies

2. Shell Programming and Scripting

Loops within loops

I am running on HPUX using ksh. I have a script that uses a loop within a loop, for some reason the script seems to hang on a particuliar record. The record is fine and hits the condition in Blue. If I kill the 1st loop process the script continues on with no problem. Begin code> <Some... (8 Replies)
Discussion started by: bthomas
8 Replies

3. UNIX for Dummies Questions & Answers

While Loops

I'm trying to create a loop that will prompt the user for 15 values, not forcing them to enter all 15. If the user enters through one or more of the prompts the null value needs to be converted to 0, otherwise set the parameter = to the value entered: ex. Please enter file no #1: 17920 ... (4 Replies)
Discussion started by: vdc
4 Replies

4. UNIX for Dummies Questions & Answers

two loops

Hi, how can I use "for" to have two loops : this is my script : for i in (A B C) do for j in (a b c) do echo $i$j done done #End I want to print out Aa Ab Ac .... But I have error message : syntax error at line 1 : `(' unexpected Many thanks before. How should I use "for" ?? (2 Replies)
Discussion started by: big123456
2 Replies

5. Shell Programming and Scripting

while loops

Hi I've a file like so: Now, I want to read my file and take ex. the Media ID and the Type for each groups of Media (Media1,Media2,...,Media(n): cat /tmp/file|\ while read FILE do while $(FILE|cut -d: -f1)=Media$i do #here will be some test, ex: #if Media ID < 23 ... (4 Replies)
Discussion started by: nymus7
4 Replies

6. Shell Programming and Scripting

Help with the 2 for loops

#!/bin/bash IFS=$'\n' A= a c b t g j i e d B= t y u i o p counter=0 found="" for i in $(cat $A) do for j in $(cat $B) do if then found="yes" fi done if then (1 Reply)
Discussion started by: vadharah
1 Replies

7. Shell Programming and Scripting

Loops

Hi All, I want to execute a script the number of times a user enters. Please can you advise on hor can I do the same. Many Thanks, Shazin (4 Replies)
Discussion started by: Shazin
4 Replies

8. UNIX for Dummies Questions & Answers

loops with tr

Hello, I'm not sure if this is more appropriate for the 'unix for dummies' or the 'unix for experts' forum because I'm new to this forum and this is the second topic I've discussed, but if you could let me know which one was more appropriate for something like this, please do! So in tr (an... (2 Replies)
Discussion started by: juliette salexa
2 Replies

9. UNIX for Advanced & Expert Users

Help with loops?

I'm trying to understand better the while and until loops, can someone help me with this example? #!/bin/bash # Listing the planets. for planet in Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune Pluto do echo $planet # Each planet on a separate line. done echo; echo for... (3 Replies)
Discussion started by: jose2802
3 Replies

10. UNIX for Dummies Questions & Answers

Need help with for loops

Why wont my for statements work? Im trying to get this script to swich to a user an if you put in a start/stop/or restart paramater to do just that for each user. I commented out the actual start/stop actions to test it just by using echos and not do anything hasty in the environment but it... (0 Replies)
Discussion started by: LilyClaro
0 Replies
RUNKIT_FUNCTION_ADD(3)							 1						    RUNKIT_FUNCTION_ADD(3)

runkit_function_add - Add a new function, similar tocreate_function(3)

SYNOPSIS
bool runkit_function_add (string $funcname, string $arglist, string $code) DESCRIPTION
PARAMETERS
o $funcname - Name of function to be created o $arglist - Comma separated argument list o $code - Code making up the function RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 A runkit_function_add(3) example <?php runkit_function_add('testme','$a,$b','echo "The value of a is $a "; echo "The value of b is $b ";'); testme(1,2); ?> The above example will output: The value of a is 1 The value of b is 2 SEE ALSO
create_function(3), runkit_function_redefine(3), runkit_function_copy(3), runkit_function_rename(3), runkit_function_remove(3), runkit_method_add(3). PHP Documentation Group RUNKIT_FUNCTION_ADD(3)
All times are GMT -4. The time now is 09:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy