I'm trying to use a foreach command with two lists. The file.txt looks like this:
I'm trying to use a foreach command to associate the two variables together. My script looks like this:
My output at the moment is:
What I want the output to be is:
Does anybody know how I can do this? I think it should be pretty simple but I'm useless at this!
Thanks in advance
Last edited by Franklin52; 06-08-2011 at 06:11 AM..
Reason: Please use code tags
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)
#!/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)
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)
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)
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)
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)
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)
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
LEARN ABOUT PLAN9
env
ENV(3) Library Functions Manual ENV(3)NAME
env - environment variables
SYNOPSIS
bind #e /env
/env/var1
/env/var2
...
DESCRIPTION
The env device serves a one-level directory containing files with arbitrary names and contents. The intention is that the file name is the
name of an environment variable (see rc(1)), and the content is the variable's current value.
When a fork(2) system call creates a new process, both the parent and the child continue to see exactly the same files in the env device:
changes made in either process can be noticed by the other. In contrast, an rfork system call with the RFENVG bit set (see fork(2)) causes
a split: initially both process groups see the same environment files, but any changes made in one process group cannot be noticed by the
other. An rfork with RFCENVG splits and then clears the environment.
SEE ALSO rc(1), fork(2)SOURCE
/sys/src/9/port/devenv.c
BUGS
A write starting at an offset after the current extent of a file yields an error instead of zero filling.
ENV(3)