I am trying to write a script which for any name given as an argument prints the list of paths to home directories of people with the name. Example:
$ shownames jakub anna
/home/users/jakubo
/home/students/j_luczka
/home/students/kubeusz
/home/students/jakub5z
/home/students/qwertinx
/home/users/lazinska
/home/students/annalaz
I am using Git Bash with files and directories on my local computer
This is what I wrote so far:
for iter in "$@"; do find "$(pwd)"/home -type d -name "*$iter*"; done;
And as expected I get the full path.
$ ./shownames.sh jakub
/c/Users/User/students/home/users/jakubo
But what if I want to get only the /home/...... part? without the full c/Users.... so on part?
Thanks a lot in advance!