Sponsored Content
Full Discussion: Using foreach with two lists
Top Forums Shell Programming and Scripting Using foreach with two lists Post 302528977 by SimonWhite on Wednesday 8th of June 2011 10:06:44 AM
Old 06-08-2011
New method

Quote:
Originally Posted by sk1418
could you paste a 'file.txt' as example, and explain what are you expecting for exactly?

---------- Post updated at 15:50 ---------- Previous update was at 15:38 ----------

oh, i see what you mean. try this : (not tested, I don't have foreach here):
Code:
#! /bin/tcsh   
set a=(`cat file.txt | grep 'var1' | cut -d ':' -f2`) 
set b=(`cat file.txt | grep 'var2' | cut -d ':' -f2`) 
 foreach f (${a}) b (${b})  
echo "var1 = " $a
echo "var2 = " $b 
 end

Thanks for the effort. I've tried your code but the output is now this:

Code:
ObsID =  914
Bin size =  2000 100 500
ObsID =  3188
Bin size =  2000 100 500
ObsID =  3189
Bin size =  2000 100 500
ObsID =  )
Bin size =  2000 100 500
ObsID =  b
Bin size =  2000 100 500
ObsID =  (
Bin size =  2000 100 500
ObsID =  2000
Bin size =  2000 100 500
ObsID =  100
Bin size =  2000 100 500
ObsID =  500
Bin size =  2000 100 500

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

foreach command ?!

SaLAam What is the best way to change a word withing a files name. I know I'm not clear enough I will give example : - I have in /test/test N number of files like this 1662_WAITING 1666_WAITING 1670_DONE 1678_DONE 1663_WAITING 1667_WAITING 1673_WAITING ... (5 Replies)
Discussion started by: geoquest
5 Replies

2. Shell Programming and Scripting

foreach/grep help!

#!/bin/bash foreach x (67402996 67402998) { grep -a x FINAL2006.dat >> MISSING_RECORDS.dat } I'm trying to pass a list to the variable x, and then grep for that string in FINAL2006.dat... Final2006.dat is in the same folder as my .sh file. I call this with a .cmd file... At any rate,... (6 Replies)
Discussion started by: JimWork
6 Replies

3. 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

4. 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

5. 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

6. UNIX for Dummies Questions & Answers

foreach question

OK, so I am extremely rusty and am just getting back to Unix after 9 years. I'm stuck on something easy. I want to search line-by-line for a string in a file, and I want to do this to a series of files in a directory. This works fine to do the search: while read i; do grep $i file2; done... (3 Replies)
Discussion started by: moldoverb
3 Replies

7. Shell Programming and Scripting

Shell Script to Create non-duplicate lists from two lists

File_A contains Strings: a b c d File_B contains Strings: a c z Need to have script written in either sh or ksh. Derive resultant files (File_New_A and File_New_B) from lists File_A and File_B where string elements in File_New_A and File_New_B are listed below. Resultant... (7 Replies)
Discussion started by: mlv_99
7 Replies

8. Shell Programming and Scripting

Learning foreach

im newbie at shell scripting. why do the following code #!/bin/tcsh setenv CBC ~/cbc/models/ foreach mix (p00p00 p02p00 p02p04) echo $mix cp $CBC/*$mix*Gyr*fits $mix/ end print(copy) only the first mix? % ./copyfromcbc.sh p00p00 wasn't it supposed to run through all words... (0 Replies)
Discussion started by: prtc
0 Replies

9. Shell Programming and Scripting

Foreach issue

Hello, I found that this foreach should work with two lists (source: Wikipedia.org) foreach i {1 2 3} j {a b c} { puts "$i $j"} == I try smth. like: With two text files: first.part second.part foreach first (`cat first.part`) second (`cat second.part`) toolcommand $first... (22 Replies)
Discussion started by: unknown7
22 Replies
dibbler-server(8)						      Dibbler							 dibbler-server(8)

NAME
dibbler-server - a portable DHCPv6 server DESCRIPTION
dibbler-server is a portable implementation of the DHCPv6 server. It supports both stateful (i.e. IPv6 address granting) and stateless (i.e. options granting) autoconfiguration. There are ports available for Linux 2.4/2.6 systems as well as MS Windows XP and 2003. They are freely available under GNU GPL version 2 (or later) license. SYNOPSIS
dibbler-server [ run | start | stop | status | install | uninstall ] OPTIONS
run - starts server in the console. Server can be closed using ctrl-c. start - starts server in daemon mode. stop - stops running server. status - shows status of the server. install - installs server as a service. This is not implemented yet. uninstall - uninstall server service. This is not implemented yet. EXAMPLES
Let's assume simple case: server should provide clients located on the eth1 link with IPv6 addresses from range 2000::100/120 and should have preference set to 7: iface eth0 { preference 7 class { pool 2000::100-2000::1ff } } Here is exmaple of server configured to work in a stateless mode (i.e. only options, not addresses are served). If client support option renewal, it should do so once in a 500 seconds: log-level 7 log-mode short stateless iface eth0 { option dns-server 2000::100,2000::101 option domain example.com, test1.example.com option ntp-server 2000::200,2000::201,2000::202 option time-zone CET option sip-server 2000::300,2000::302,2000::303,2000::304 option sip-domain sip1.example.com,sip2.example.com option nis-server 2000::400,2000::401,2000::404,2000::405,2000::405 option nis-domain nis.example.com option nis+-server 2000::501,2000::502 option nis+-domain nisplus.example.com option lifetime 500 } More examples can be found in the User's Guide. FILES
All files are created in the /var/lib/dibbler directory. Dibbler server reads /var/lib/dibbler/server.conf file. During operation, Dibbler saves various file in that directory. Log file is named client.log. STANDARDS
This implementation aims at conformance to the following standards: RFC 3315 DHCP for IPv6 RFC 3319 SIP options for DHCPv6 RFC 3646 DNS server options for DHCPv6 RFC 3736 Stateless DHCPv6 RFC 3898 NIS options for DHCPv6 Also options specified in following drafts are implemented: draft-ietf-dhc-dhcpv6-opt-timeconfig-03.txt NTP and timezone options. draft-ietf-dhc-dhcpv6-opt-lifetime-00.txt Option renewal. BUGS
Bugs are tracked with bugzilla, available at http://klub.com.pl/bugzilla/. If you belive you have found a bug, don't hesitate to report it. AUTHOR
Dibbler was developed as master thesis on the Technical University of Gdansk by Tomasz Mrugalski and Marek Senderski. Currently Marek has not enough free time, so this project is being developed by Tomasz Mrugalski. Authors can be reached at thomson@klub.com.pl and msend@o2.pl SEE ALSO
There is dibbler-client(8) manual page. You are also advised to take a look at project website located at http://klub.com.pl/dhcpv6/. As far as authors know, this is the only Windows DHCPv6 stateful implementation available. It is also one of two freely available under Linux. The other Linux implementation is available at http://dhcpv6.sourceforge.net, but it is rather outdated and seems not being actively devel- oped. GNU
2004-12-11 dibbler-server(8)
All times are GMT -4. The time now is 05:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy