Thank you so much bakunin. If I'm understanding correctly, you're telling me to use the absolute path in my script.
Actually i am telling you to use only absoulte paths in all your scripts.
Quote:
Originally Posted by saleheen
When I say
shouldn't it go to the child directories where my input files are?
Yes, it should. I looked at your script in post #1 and there it reads:
Quote:
Originally Posted by saleheen
I take it that has already been dealt with, yes?
Quote:
Originally Posted by saleheen
Normally what I do is I go to each child directory one by one and call my script like this:
OK. What i suggest you should do is to give the directory you would go as parameter to the script. The script itself would then go to the directory, do what it has to do, and so on. I would write your script this way (all the seds put together, not used "-i" because it is not portable):
etc., etc.. Notice that the names of the 3 files you use are defined only once in the whole script, so it is easy to change them. Also notice, that because they are all declared with a full path the script only uses absolute paths now.
/PS: Furthermore, the script now understands the directory to work on as a parameter, so instead of the (inherently error-prone)
you can do the (much cleaner)
You might post an example for the ".cells"-files you work on because i sense that for what you do there should be an easier solution than the one you found. Most probably some lines of awk will do everything your script does but ten times faster.
My suggestion regarding shells is: NEVER EVER USE CSH - it can't be stressed enough. csh is unpredictable as hell and strongly discouraged for interactive use, for scripting it is outright verboten!
If you want to write shell scripts use a POSIX-compatible shell. There are two: Korn shell (ksh) and Bourne-Again-Shell (bash). IMHO Korn Shell is better suited for scripting, but this may be personal taste as much as professional opinion. Any of the two will be suited for what your needs seem to be. It should be mentioned that the two shells languages differ only in details and if you know one you know most of the other. For what i think you want to do they are almost identical.
I do not know any bash books. For Korn Shell i can wholeheartedly recommend Barry Rosenbergs book "Hands-On KornShell93 Programming".
Thanks you so much bakunin, we had our eid celebrations yesterday, that's why I'm posting late. I have changed my shell into bash so I think life will be a little bit easier even for a newbie like me. Thanks again and eid mubarak
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)
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)
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)
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)
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)
Hey all,,
I know cshell is harmful:) but I am using this just "to know" - for educational purposes!... not for a long-term use.
lets say i have a list..
set arr=(x y z e f)
I wanna iterate the list with foreach ,, not with while.!!
foreach i $arr
echo $i
end
does not work (2 Replies)
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)
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)
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)