Bash script to automatically create symlinks to subdirectories in a tree

后端 未结 3 1811
借酒劲吻你
借酒劲吻你 2021-01-14 14:54

Ok, this is my third try posting this, maybe I\'m asking the wrong question!!

It\'s been a few years since I\'ve done any shell programming so I\'m a bit rusty...

3条回答
  •  佛祖请我去吃肉
    2021-01-14 15:43

    Use a for loop.

    for name in $(find $from_dir -mindepth 3 -maxdepth 3 -type d); do
      ln -s $name $to_dir
    done
    

    Xargs has issues where the input from the pipe goes at the end of the command. What you want is multiple commands, not just 1 command.

    My experience with doing things within the find command can sometimes be slow, although it does get the job done.

提交回复
热议问题