Sponsored Content
Full Discussion: foreach loop + 2 variables
Top Forums Shell Programming and Scripting foreach loop + 2 variables Post 302201688 by era on Tuesday 3rd of June 2008 12:47:26 AM
Old 06-03-2008
You can do that with while:

Code:
while read i j; do
  stuff with i
  stuff with j
done <<HERE
firsti firstj
secondi secondj can have several fields actually
thirdi thirdj -- it splits on whitespace
fourthi fourthj; but only as many as necessary
fifthi fifthj ... and the remainder is unsplit
HERE

It's not exactly what you asked for, but hopefully close enough.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

foreach loop question

Hello, I am new at this forum so please bare with me on this. Within a given directory, I have a list of files in which in each file, I would like to do a substitution. I would like to substitute the string mlcl to mll in each file using the foreach command. I dont quite get how to do that. If... (7 Replies)
Discussion started by: clipski
7 Replies

2. Shell Programming and Scripting

Foreach loop

What am I doing wrong with this foreach loop? foreach var ($argv) @sum = $sum + $var (4 Replies)
Discussion started by: haze21
4 Replies

3. Shell Programming and Scripting

foreach loop

Hi Guys, I have a loop which uses a wildcard i.e. foreach f (*) but when I execute the tcsh file in unix then it gives me an error ->>>>>>>foreach: words not parenthesized<<<<<<<<<<- Any help. (1 Reply)
Discussion started by: abch624
1 Replies

4. Shell Programming and Scripting

foreach loop

Hi everyone Does anyone know what is wrong with this script. i keep getting errors foreach filename (`cat testing1`) set string=$filename set depth=`echo "$string" echo $depth end the error is the following testing: line 1: syntax error near unexpected token `(' testing: line 1:... (3 Replies)
Discussion started by: ROOZ
3 Replies

5. UNIX for Advanced & Expert Users

Problem with foreach loop

Hi All, Is there any problem with the below 'foreach' loop? foreach risk_factor ($(cat "$rf_list")) where "rf_list=$SCRIPT/Utility/rflist.txt " I'm wondering, it is throwing below error message: syntax error at line 34: `(' unexpected Any idea/suggestions ? Thanks in advance /... (7 Replies)
Discussion started by: ganapati
7 Replies

6. Shell Programming and Scripting

Using sed with a foreach loop

So I am back again beating my head against the wall with a shell script and getting a headache! I want to change each year in a file (1980, 1981, 1982, 1983, etc.) to the same year followed by a tab. The input is "blah blah (1980) blah blah". I want to get "blah blah (1980 ) blah blah".... (2 Replies)
Discussion started by: Peggy White
2 Replies

7. UNIX for Dummies Questions & Answers

Using the Foreach loop, Needing help

I am trying to make a script for my Counter-Strike: Source servers. What i am wanting it to do is for it to restart each server, the only way i can think of doing this in through for each. Years what i have at the moment. server_start() { START=`ps x | grep SCREEN | grep $SRV | cut -d '?' -f... (5 Replies)
Discussion started by: grahamn95
5 Replies

8. Shell Programming and Scripting

foreach loop problem

Dear all, I wrote a script to download files and move files in directories according to their name. Now here is the problem: Both p101 and p360 data download successfully, but when I move them according to the year and month, only p101 data can be placed at the right location, p360,... (1 Reply)
Discussion started by: handsonzhao
1 Replies

9. UNIX for Dummies Questions & Answers

foreach loop in csh

Hi everyone I'm new to unix and encountered a small problem i couldnt find out a reason why it doesn't work..please help.. in my csh script when i tried to use the foreach loop like this: foreach x ( ls ) echo $x end when i tried to run it, it printed out 'ls' to the std out instead of... (3 Replies)
Discussion started by: ymc1g11
3 Replies

10. Shell Programming and Scripting

Foreach loop with two variables

I need to put together a script that will take the contents of two different files (database name and database owner) and put them in two variables within a line: foreach x (`cat /local/hd3/dba/tools/build_db_scripts/dbs`) foreach z (`cat /local/hd3/dba/tools/build_db_scripts/dbas`)... (6 Replies)
Discussion started by: deneuve01
6 Replies
wml::all(3)							     EN Tools							       wml::all(3)

NAME
wml::all - WML Include Files Of All Categories SYNOPSIS
#use wml::all DESCRIPTION
This includes all existing standard WML include files of all categories. Use it only when you are a really lazy webmaster which just wants all features WML can provide ;-) It is always better to include one of the "wml::xxx::all" include files. The following categories currently exists: Standard (std) Here you can find all standard tagsets which everybody usually uses all the time. Webdesign (des) These are tagsets which help webdesigners of the 3rd generation fighting against the puristic plain HTML. Use with care. Formatting (fmt) Here you can find formatting environments, i.e. usually container tags which do special formatting. Import (imp) Here you can find import tags, i.e. usually tags which import external data and converts them to HTML. Support (sup) Some support stuff which is used in other include files. System (sys) All system related stuff. User (usr) The user specific include files. Should be extended by the webmaster for his users. AUTHOR
Ralf S. Engelschall rse@engelschall.com www.engelschall.com REQUIRES
Internal: P1 External: -- SEE ALSO
wml::des::all(3), wml::fmt::all(3), wml::imp::all(3), wml::std::all(3), wml::sup::all(3), wml::sys::all(3), wml::usr::all(3). EN Tools 2014-04-16 wml::all(3)
All times are GMT -4. The time now is 10:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy