Niroj
1
Hi All,
path1="/opt/YAK/N78"
path2="/opt/YAK/N79"
I need to do such a way that when I will invoke "cd $path1" it should redirect me to $path2.
Humm.. tried to use link, alias and export ....but nothing is working...
Another one is it should work for any user login....
Can we cheat link error messages when we use "/"?...
Regards,
Niroj
ctsgnb
2
If you are trying to go in a PATH you are not authorized to, then it is normal that you could not get in.
Otherwise, alias or ln should work.
methyl
3
You cannot achieve this effect without changing $path1.
For example.
path1="${path2}" ; export path1
This seems clumsy to me, but I think it does what you want:
function cd()
{
path1="/opt/YAK/N78"
path2="/opt/YAK/N79"
command cd "$@"
if [ "$PWD" = "$path1" ]; then
command cd "$path2"
fi
}
Or rename the /opt/YAK/N78 to /opt/YAK/N78.bak en create a symbolic link:
mv "$path1" "$path1.bak"
ln -s "$path2" "$path1"