HOW: Shell script accessing files located in individual logged in user.
I have below scenario, I hope this could be possible, but as of now no idea how to implement this.
Mount point in this location /abc/mp, and there will different users who will be executing one the file shell1.sh file located in /abs/mp, but every user will execute this shell1.sh file from their login
(somtehing like this /aaa/bbb/home/usr1)
I am sure that above step can be implemented by creating link in /abc/mp for each individual users
Now real question is
In my shell1.sh file which is in /abc/mp, have to pick one of the file dynamically (I mean not hardcoded path/file) from certain folder for logged in user
i.e. for example
- File in /abc/mp is shell1.sh
- Individual logged in user is usr1
So usr1 will execute this shell1.sh file using link
The shell1.sh should be able to pick the file namely mydatafile.txt from individual logged in user from certain folder in /aaa/bbb/home/usr1/dump
(Similarly if usr2 executes this shell1.sh then shell file should able to pick mydatafile.txt located in usr2's location that is /aaa/bbb/home/usr2/dump )
I just like to know how this can be implemented, might be very simple but I am not aware of this.
There is an environmental variable called $HOME which gives the home directory of the currently logged user. Try echo $HOME
Another shortcut is the tilde '~' which refers to the user's home directory. Try echo ~/