April 17th, 2002, 12:07 PM
check to see if file is from other dir.......
is it possible to test if when running a script that the file the user is attempting to use is from a different folder.
is the most simple tool grep??
basically this is the code below
for file do ls $file | grep '/' > /dev/null 2>&1
if [ $? -ne 1 ]
then echo "blah" > &2
Thing is if the file doesnt exsist then i get 2 error one because error messages dont go through pipes and another one that i have put for that paticular occurance.
can anyone suggest any other better ways of doing it.
April 17th, 2002, 05:41 PM
Don't know exactly what you're trying to do. For the 2nd one add a number before $? like so it's always non-empty.
April 18th, 2002, 05:53 AM
basically when people run my script i want to make sure that the files they use for the script is not from another directory, they can only run the script if the files are in the current directory.
i though if i use grep it could look at the path and make sure there isnt any "/" in the path.