I have 2 link directories in ~, ~/PathA (a git directory) and ~/PathB. The ~/PathA is a subdirectory of ~/PathB. Those two are linked to other physical disk. I linked a lot of files to file under ~/PathA/config/ in my ~. I want find out all those link files. show "xxxxx -> yyyyy" format.
This method is often used when we use configuration files from old/other machine.
If I write a script or use pipe, it is easy can do but something ugly. But I want if only use find command I can do it.
Edit: After test many time, I got it. The most important place is -lname and -print.
▶ find ~ -type l ! -path '/home/eexpss/磁盘' ! -path '/home/eexpss/bin' -lname '/home/eexpss/bin/config/*' -printf "%p -> %l\n" /home/eexpss/.local/share/applications -> /home/eexpss/bin/config/.local+share+applications /home/eexpss/.local/share/nautilus/scripts -> /home/eexpss/bin/config/.local+share+nautilus+scripts /home/eexpss/.vimrc -> /home/eexpss/bin/config/fedora.vimrc /home/eexpss/.proxy.pac -> /home/eexpss/bin/config/.proxy.pac /home/eexpss/.bash_aliases -> /home/eexpss/bin/config/fedora.bash_aliases /home/eexpss/.icons -> /home/eexpss/bin/config/.icons/ find: ‘/home/eexpss/磁盘/lost+found’: Permission denied find: ‘/home/eexpss/磁盘/eexp/.gvfs’: Permission denied /home/eexpss/.vim -> /home/eexpss/bin/config/.vim /home/eexpss/.gitconfig -> /home/eexpss/bin/config/.gitconfig
I will accept Stéphane Chazelas' answer. thanks.