recursion

Tags
recursion, shell scripts

 
Thread Tools Search this Thread
# 1  
Old 08-25-2002
recursion

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]
endif
shift allFiles
end

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?
# 2  
Old 08-26-2002
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 04:35 AM..

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Copy directory withOUT recursion chebarbudo UNIX for Beginners Questions & Answers 7 07-25-2018 12:19 PM
BIND 9, disable recursion snchaudhari2 Solaris 0 03-13-2018 12:42 AM
Bash variable recursion yifangt Shell Programming and Scripting 7 08-08-2013 09:54 PM
Recursion list for rm -R in find port43 UNIX for Advanced & Expert Users 5 06-27-2013 10:15 PM
Recursion in a bash script mistsong1 UNIX for Dummies Questions & Answers 6 04-25-2013 05:29 PM
script recursion superpointer Shell Programming and Scripting 6 02-12-2011 09:24 PM
C Recursion (explain) seede Programming 5 04-26-2010 09:30 PM
recursion script problem mac4rfree Shell Programming and Scripting 3 07-21-2009 08:15 AM
Recursion joshighanshyam Programming 5 12-03-2008 12:15 PM
KSH: recursion into subdirectories? Wotan31 Shell Programming and Scripting 2 09-24-2008 04:49 PM
How to remove old files without recursion? nir_s Shell Programming and Scripting 5 04-27-2008 11:43 AM
Help Help Help in recursion murtaza Shell Programming and Scripting 6 03-29-2007 11:26 AM
A Question On Recursion In Ksh marlonus999 Shell Programming and Scripting 1 01-11-2007 07:09 AM
allow recursion on dns server? xnightcrawl UNIX for Advanced & Expert Users 1 03-29-2006 10:36 AM
recursion too deep swamy455 Shell Programming and Scripting 3 07-18-2005 04:18 PM