bash - linux find file and create hardlink -


I am trying to find a file, then create a hard link in the same directory with the same name. But this is not working, if I take the -exec and close, it displays a result I am already working with CP, but I have decided to make a hard link instead.

  find -name "* sample *" -exec link {} ~ / {} \:  

The problem is that the path found in the {} file; Therefore, the ~ / {} path is not in the ~ , but there is some non-existent sub-directory.

I did not find any way to get it {} find using basename neither xargs .

This is a solution that works but is unsafe:

find -name "* sample *" | While reading f; Link "$ f" "$ HOME / $ {f ## * /}";

You can add a filter between find and read to get rid of "dangerous" file names.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -