Shell Programming and Scripting

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.


👤 Login to reply

Old 08-25-2002
gsjf gsjf is offline
Registered User
Join Date: Aug 2002
Last Activity: 3 September 2002, 7:06 AM EDT
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

I'm using the UNIX csh and i wish to use recursion to nav my way up (or down as it is) a given folder.

My little test script is called "r" and takes a folder as argv[1] (or $1)

#!/bin/tcsh -f
set allFiles = `ls -A $argv[1]`
cd $argv[1]
while ($#allFiles)
if (-d $allFiles[1]) then
echo $allFiles[1]
# do whatever...
r $allFiles[1]
shift allFiles

echo done.

however once it chages into a given dir the script "r" is no longer in the new dir and thus the process fails. I'm not the super user so I can not dump the script "r" in "bin". Can anyone help me do something similair?
Sponsored Links
Old 08-26-2002
peter.herlihy peter.herlihy is offline
Registered User
Join Date: Nov 2001
Last Activity: 1 August 2006, 11:51 AM EDT
Location: New Zealand
Posts: 333
Thanks: 0
Thanked 0 Times in 0 Posts
Just use the absolute path of r.

instead of
r $allFiles[1]

use /full/path/name/r $allFiles[1]

That was r will always be found wherever you are. At the moment 'r' is only going to be found in the directory you are in.

Alternatively add the location of 'r' to your PATH. Same effect as putting it in bin - the reason that you could find it if it was in bin (regardless of where you are) is that bin is in your path......same logic.

Last edited by peter.herlihy; 08-26-2002 at 03:35 AM..
Sponsored Links
👤 Login to reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
script recursion superpointer Shell Programming and Scripting 6 02-12-2011 08:24 PM
C Recursion (explain) seede Programming 5 04-26-2010 08:30 PM
Recursion joshighanshyam Programming 5 12-03-2008 11:15 AM
KSH: recursion into subdirectories? Wotan31 Shell Programming and Scripting 2 09-24-2008 03:49 PM
Help Help Help in recursion murtaza Shell Programming and Scripting 6 03-29-2007 10:26 AM

All times are GMT -4. The time now is 11:11 PM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
Show Password

Not a Forum Member?
Forgot Password?