bash: PWD minus last two directories
I've got a script that where I'm trying to check the existance of a file two directories above the working directory. i.e. working directory is /home/bozo/ideas/thoughts and I'm interested in files in /home/bozo
How do I manipulate PWD (or something) into a variable that I can check? I tried this but with no success. Code:
outputfilename=bozo.mpg i.e. Code:
${PWD##*/} TIA for any help recieved, Rich |
try
Code:
IFS=/ |
thx.
I thought a parameter subsitution would do the trick. I don't yet fully understand how this is working, but I'll keep trying to parse it. When I tried this I'm now getting "script.sh: 60: Bad substitution" which is indicating the line Code:
echo "/${*:1:$(( $# - 2 ))}" |
I'd rather return to the original issue. Why extracting this information from $PWD when the notation ../../ should work instead? Can you post the output of the following command?
Code:
bash -x script.sh The content of script.sh should be a simple test script like: Code:
#!/bin/bash |
colucix, that helps a bunch. Turns out I was dumb and was missing the extension, but couldn't tell. Debug like that will be an invaluable tool!
Thanks! |
All times are GMT -5. The time now is 05:45 AM. |