Results 1 to 5 of 5
I know this does'nt work but how in my script would I get the script to confirm it's directory is in.
if [ $pwd -eq $LOG_DIR ];
then
echo "work"
...
- 03-22-2011 #1Just Joined!
- Join Date
- Jan 2011
- Posts
- 19
how to get my script to confirm the directory it is in
I know this does'nt work but how in my script would I get the script to confirm it's directory is in.
if [ $pwd -eq $LOG_DIR ];
then
echo "work"
else
echo "did'nt work"
Thanks
Tom
- 03-22-2011 #2
variables in bash are case sensitive you need $PWD
- 03-22-2011 #3
Despite the fact that this comment is rather off topic:
A script should not care about which working directory it is being executed at unless it is designed to do so. I.e. if a script removes files from a directory and someone else executes it in error that one could become rude, especially if the other one was me and $PWD was ~.
- 03-23-2011 #4
- 03-23-2011 #5
If the script is supposed to act on a certain directory, I think that you have two choices that are better than what you are doing here:
1) Don't use the current directory, use the target directory. For example, if printing every file in the current directory, say "cat $TARGET_DIR/*", not "cat *". This way, the current directory doesn't matter.
2) Make the first thing you do to cd to the target directory:
Code:cd $TARGET_DIR cat *
DISTRO=Arch
Registered Linux User #388732


Reply With Quote
