10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Just started shell scripting for the first time today :D Can anyone tell me why I get the error "foreach: Words not parenthesized." for my following code? The program takes in a list of arguments.
foreach card ($argv)
echo Hello
end (3 Replies)
Discussion started by: pkuebler
3 Replies
2. Shell Programming and Scripting
I'm trying to grab a list of file names from a directory, then process those files 5 at a time. In the link below. Instead of using files I'm using the files array which contains 15 strings starting with AAA.
So I'm trying to assign $fileset 5 of the strings at a time to pass to a command. So... (4 Replies)
Discussion started by: zBernie
4 Replies
3. UNIX for Dummies Questions & Answers
Hi
You might find it very trivial but actually don't know how to loop through all sub-directories and their child directories into a csh. bash was easier I believe but here I am, stuck with csh. So elaborately here's my problem:
Let's say I have my parent directory named C-H/ under which I have... (15 Replies)
Discussion started by: saleheen
15 Replies
4. Shell Programming and Scripting
A simple script:
#!/bin/bash
test=test
test1=(test1 test2 test3)
echo ${test1
}
ssh server 'echo '$test'; echo '${test1
}' ; echo '${test1}' ; for m in $(seq 1 $(echo '${test1
}' | tr " " "\n" | wc -l)); do echo $m ; echo '${test1}'; done'Here is the result:
test1 test2 test3
testing... (5 Replies)
Discussion started by: mharald
5 Replies
5. Shell Programming and Scripting
I'm trying to send the file list as parameter to another job and execute it.
But the loop doesn't work, the inner job is running only once and not twice as expected
for filelist in $(ls -rt *.txt | tail -2)
do
echo $filelist
export filelist
cmd="$Program -config $configfile -autoexec... (11 Replies)
Discussion started by: asandy1234
11 Replies
6. UNIX for Dummies Questions & Answers
I need to load an XML file and loop through a list of nodes in it to execute a shell script for each one using the attributes for each node as parameters for the script. Any ideas? Any help will be much appreciated. (1 Reply)
Discussion started by: bradlecat
1 Replies
7. UNIX for Dummies Questions & Answers
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
8. UNIX for Dummies Questions & Answers
Hello all,
I'm working on a foreach loop to compare a couple sets of data. However, each datafile includes a header row. I'm wondering if it is possible to tell the foreach loop to skip the first line of data.
I've been using the basic code as follows:
foreach line ("`file.csv`")
set... (2 Replies)
Discussion started by: meteorologistks
2 Replies
9. Shell Programming and Scripting
I have a foreach loop in a csh script and I noticed that it tries to find the files with the pattern *$searchpt* in the file name. I'm confused as I never specified checking for the files.
foreach f ( *$searchpt* )
set fnew = `echo $f | awk -v searchpat=$searchpt \
... (1 Reply)
Discussion started by: kristinu
1 Replies
10. Shell Programming and Scripting
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