How can I “relink” a lot of broken symlinks?How I can change all symlink to the new pathMove a file and...

Implications of cigar-shaped bodies having rings?

How does Captain America channel this power?

Can someone publish a story that happened to you?

Contradiction proof for inequality of P and NP?

"You've called the wrong number" or "You called the wrong number"

What's the name of these pliers?

Is there any official lore on the Far Realm?

A strange hotel

Is it idiomatic to construct against `this`

Pulling the rope with one hand is as heavy as with two hands?

Map of water taps to fill bottles

Why does nature favour the Laplacian?

What is causing the white spot to appear in some of my pictures

can anyone help me with this awful query plan?

How to fry ground beef so it is well-browned

What is the philosophical significance of speech acts/implicature?

Pre-plastic human skin alternative

How much cash can I safely carry into the USA and avoid civil forfeiture?

Get consecutive integer number ranges from list of int

Elements other than carbon that can form many different compounds by bonding to themselves?

How to not starve gigantic beasts

What is the most expensive material in the world that could be used to create Pun-Pun's lute?

"The cow" OR "a cow" OR "cows" in this context

Alignment of various blocks in tikz



How can I “relink” a lot of broken symlinks?


How I can change all symlink to the new pathMove a file and re-target all of its symlinksHow to Relink these symlinks after moving the system?How can I find broken symlinksHow can I edit symlinks?Sharing a project tree between environmentsread only symlink or something similar?Create symlink tree in existing directoriesOS X: Can `ls` show broken symlinks?Symlink to file which does not exist yetHow to Relink these symlinks after moving the system?Do hard links really take up so much disk space?zip command show warnings “name not matched” about symlinks, outside of my working directory, pointing to non-existing target






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







50















I have a directory tree which has a bunch of symbolic links to files under /home... however, I have moved /home to /mnt/home and need a way to "relink" all of the symlinks. Does such functionality exist or do I need to write a script to do so?



As an example, I have something like the following:



[root@trees ~]# ls -l /mnt/home/someone/something
total 4264
lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 a -> /home/someone/someotherthing/a
lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 b -> /home/someone/someotherthing/b
lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 c -> /home/someone/someotherthing/c
lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 d -> /home/someone/someotherthing/d
lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 e -> /home/someone/someotherthing/e

/mnt/home/someone/something/subdir:
total 4264
lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 a -> /home/someone/someotherthing/subdir/a
lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 b -> /home/someone/someotherthing/subdir/b
lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 c -> /home/someone/someotherthing/subdir/c
lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 d -> /home/someone/someotherthing/subdir/d
lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 e -> /home/someone/someotherthing/subdir/e


I want a command which will find all the symlinks and relink to the same places but underneath /mnt/home instead of /home



Does such a command exist?










share|improve this question





























    50















    I have a directory tree which has a bunch of symbolic links to files under /home... however, I have moved /home to /mnt/home and need a way to "relink" all of the symlinks. Does such functionality exist or do I need to write a script to do so?



    As an example, I have something like the following:



    [root@trees ~]# ls -l /mnt/home/someone/something
    total 4264
    lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 a -> /home/someone/someotherthing/a
    lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 b -> /home/someone/someotherthing/b
    lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 c -> /home/someone/someotherthing/c
    lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 d -> /home/someone/someotherthing/d
    lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 e -> /home/someone/someotherthing/e

    /mnt/home/someone/something/subdir:
    total 4264
    lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 a -> /home/someone/someotherthing/subdir/a
    lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 b -> /home/someone/someotherthing/subdir/b
    lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 c -> /home/someone/someotherthing/subdir/c
    lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 d -> /home/someone/someotherthing/subdir/d
    lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 e -> /home/someone/someotherthing/subdir/e


    I want a command which will find all the symlinks and relink to the same places but underneath /mnt/home instead of /home



    Does such a command exist?










    share|improve this question

























      50












      50








      50


      23






      I have a directory tree which has a bunch of symbolic links to files under /home... however, I have moved /home to /mnt/home and need a way to "relink" all of the symlinks. Does such functionality exist or do I need to write a script to do so?



      As an example, I have something like the following:



      [root@trees ~]# ls -l /mnt/home/someone/something
      total 4264
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 a -> /home/someone/someotherthing/a
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 b -> /home/someone/someotherthing/b
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 c -> /home/someone/someotherthing/c
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 d -> /home/someone/someotherthing/d
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 e -> /home/someone/someotherthing/e

      /mnt/home/someone/something/subdir:
      total 4264
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 a -> /home/someone/someotherthing/subdir/a
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 b -> /home/someone/someotherthing/subdir/b
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 c -> /home/someone/someotherthing/subdir/c
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 d -> /home/someone/someotherthing/subdir/d
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 e -> /home/someone/someotherthing/subdir/e


      I want a command which will find all the symlinks and relink to the same places but underneath /mnt/home instead of /home



      Does such a command exist?










      share|improve this question














      I have a directory tree which has a bunch of symbolic links to files under /home... however, I have moved /home to /mnt/home and need a way to "relink" all of the symlinks. Does such functionality exist or do I need to write a script to do so?



      As an example, I have something like the following:



      [root@trees ~]# ls -l /mnt/home/someone/something
      total 4264
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 a -> /home/someone/someotherthing/a
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 b -> /home/someone/someotherthing/b
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 c -> /home/someone/someotherthing/c
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 d -> /home/someone/someotherthing/d
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 e -> /home/someone/someotherthing/e

      /mnt/home/someone/something/subdir:
      total 4264
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 a -> /home/someone/someotherthing/subdir/a
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 b -> /home/someone/someotherthing/subdir/b
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 c -> /home/someone/someotherthing/subdir/c
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 d -> /home/someone/someotherthing/subdir/d
      lrwxrwxrwx 1 jnet www-data 55 2011-08-07 13:50 e -> /home/someone/someotherthing/subdir/e


      I want a command which will find all the symlinks and relink to the same places but underneath /mnt/home instead of /home



      Does such a command exist?







      command-line symlink






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 8 '11 at 23:04









      JoshJosh

      3,80664365




      3,80664365






















          3 Answers
          3






          active

          oldest

          votes


















          52














          There is no command to retarget a symbolic link, all you can do is remove it and create another one. Assuming you have GNU utilities (e.g. under non-embedded Linux or Cygwin), you can use the -lname primary of find to match symbolic links by their target, and readlink to read the contents of the link. Untested:



          find /mnt/home/someone/something -lname '/home/someone/*' 
          -exec sh -c 'ln -snf "/mnt$(readlink "$0")" "$0"' {} ;


          It would be better to make these symbolic links relative. There's a convenient little utility called symlinks (originally by Mark Lords, now maintained by J. Brandt Buckley), present in many Linux distributions.
          Before the move, or after you've restored valid links as above, run symlinks -c /mnt/home/someone/something to convert all absolute symlinks under the specified directory to relative symlinks unless they cross a filesystem boundary.






          share|improve this answer


























          • No offense, this is a great one-liner, but Bash's string substitution could probably do some magic w.r.t. the path change and would be easier.

            – 0xC0000022L
            Feb 8 '12 at 20:30











          • @STATUS_ACCESS_DENIED How so? The only string operation is to prepend /mnt to a path; you need no fancier string operation than concatenation.

            – Gilles
            Feb 8 '12 at 20:41











          • @Gilles: sorry, I was thinking more about your remark with the relative paths. For an exact "translation" of your example you are of course right.

            – 0xC0000022L
            Feb 8 '12 at 20:55



















          13














          I know this is not exactly what the author is requesting but it seems they already have their answer so I'm adding this for others like me who stumble upon the question.



          The following should help if a more flexible solution is required such as having a bunch of broken symbolic links which can be fixed by replacing part of the symbolic link's targets.



          eg. After a change of username, to replace the old username with the new username in the target of many links, after the move had already been done. Create a script called replace-simlinks shown below:



          #!/bin/bash
          link=$1
          # grab the target of the old link
          target=$(readlink -- "$1")

          # replace the first occurrence of oldusername with newusername in the target string
          target=${target/oldusername/newusername}

          # Test the link creation
          echo ln -s -- "$target" "$link"

          # If the above echo shows the correct commands are being issued, then uncomment the following lines and run the command again
          #rm $link
          #ln -s "$target" "$link"


          and call it with the following command:



          find /home/newusername/ -lname '/home/oldusername/*' -exec ~/bin/replace-simlinks {} ;


          Hope this help somebody



          edit: Thanks Gilles for the kickstart on this script and the tip about using the symlinks script to make the links relative.






          share|improve this answer





















          • 1





            I find this solution better because it uses a string replace, which helps in cases where you have to change the name of a folder in the middle of the path. The solution is also quite easy to modify to perform more complex transformations if required.

            – Gallaecio
            Nov 29 '14 at 22:56











          • I'd recommend quoting the arguments to the string substitution, as that must be done to use slashes, e.g. for the path in the OP's question. target=${target/"/home"/"/mnt/home"} Very helpful, though. Thanks.

            – Walter Nissen
            Nov 29 '18 at 18:08





















          3














          Create /home as a symlink to /mnt/home, and all the existing symlinks will be valid again.






          share|improve this answer



















          • 2





            Bind-mounting often tends to be less fragile than symlinks in scenarios where programs are aware of symlinks and act differently depending on the fact ...

            – 0xC0000022L
            Feb 8 '12 at 20:27










          protected by Community Oct 22 '14 at 11:11



          Thank you for your interest in this question.
          Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



          Would you like to answer one of these unanswered questions instead?














          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          52














          There is no command to retarget a symbolic link, all you can do is remove it and create another one. Assuming you have GNU utilities (e.g. under non-embedded Linux or Cygwin), you can use the -lname primary of find to match symbolic links by their target, and readlink to read the contents of the link. Untested:



          find /mnt/home/someone/something -lname '/home/someone/*' 
          -exec sh -c 'ln -snf "/mnt$(readlink "$0")" "$0"' {} ;


          It would be better to make these symbolic links relative. There's a convenient little utility called symlinks (originally by Mark Lords, now maintained by J. Brandt Buckley), present in many Linux distributions.
          Before the move, or after you've restored valid links as above, run symlinks -c /mnt/home/someone/something to convert all absolute symlinks under the specified directory to relative symlinks unless they cross a filesystem boundary.






          share|improve this answer


























          • No offense, this is a great one-liner, but Bash's string substitution could probably do some magic w.r.t. the path change and would be easier.

            – 0xC0000022L
            Feb 8 '12 at 20:30











          • @STATUS_ACCESS_DENIED How so? The only string operation is to prepend /mnt to a path; you need no fancier string operation than concatenation.

            – Gilles
            Feb 8 '12 at 20:41











          • @Gilles: sorry, I was thinking more about your remark with the relative paths. For an exact "translation" of your example you are of course right.

            – 0xC0000022L
            Feb 8 '12 at 20:55
















          52














          There is no command to retarget a symbolic link, all you can do is remove it and create another one. Assuming you have GNU utilities (e.g. under non-embedded Linux or Cygwin), you can use the -lname primary of find to match symbolic links by their target, and readlink to read the contents of the link. Untested:



          find /mnt/home/someone/something -lname '/home/someone/*' 
          -exec sh -c 'ln -snf "/mnt$(readlink "$0")" "$0"' {} ;


          It would be better to make these symbolic links relative. There's a convenient little utility called symlinks (originally by Mark Lords, now maintained by J. Brandt Buckley), present in many Linux distributions.
          Before the move, or after you've restored valid links as above, run symlinks -c /mnt/home/someone/something to convert all absolute symlinks under the specified directory to relative symlinks unless they cross a filesystem boundary.






          share|improve this answer


























          • No offense, this is a great one-liner, but Bash's string substitution could probably do some magic w.r.t. the path change and would be easier.

            – 0xC0000022L
            Feb 8 '12 at 20:30











          • @STATUS_ACCESS_DENIED How so? The only string operation is to prepend /mnt to a path; you need no fancier string operation than concatenation.

            – Gilles
            Feb 8 '12 at 20:41











          • @Gilles: sorry, I was thinking more about your remark with the relative paths. For an exact "translation" of your example you are of course right.

            – 0xC0000022L
            Feb 8 '12 at 20:55














          52












          52








          52







          There is no command to retarget a symbolic link, all you can do is remove it and create another one. Assuming you have GNU utilities (e.g. under non-embedded Linux or Cygwin), you can use the -lname primary of find to match symbolic links by their target, and readlink to read the contents of the link. Untested:



          find /mnt/home/someone/something -lname '/home/someone/*' 
          -exec sh -c 'ln -snf "/mnt$(readlink "$0")" "$0"' {} ;


          It would be better to make these symbolic links relative. There's a convenient little utility called symlinks (originally by Mark Lords, now maintained by J. Brandt Buckley), present in many Linux distributions.
          Before the move, or after you've restored valid links as above, run symlinks -c /mnt/home/someone/something to convert all absolute symlinks under the specified directory to relative symlinks unless they cross a filesystem boundary.






          share|improve this answer















          There is no command to retarget a symbolic link, all you can do is remove it and create another one. Assuming you have GNU utilities (e.g. under non-embedded Linux or Cygwin), you can use the -lname primary of find to match symbolic links by their target, and readlink to read the contents of the link. Untested:



          find /mnt/home/someone/something -lname '/home/someone/*' 
          -exec sh -c 'ln -snf "/mnt$(readlink "$0")" "$0"' {} ;


          It would be better to make these symbolic links relative. There's a convenient little utility called symlinks (originally by Mark Lords, now maintained by J. Brandt Buckley), present in many Linux distributions.
          Before the move, or after you've restored valid links as above, run symlinks -c /mnt/home/someone/something to convert all absolute symlinks under the specified directory to relative symlinks unless they cross a filesystem boundary.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 8 '15 at 12:28

























          answered Aug 9 '11 at 0:10









          GillesGilles

          550k13111191633




          550k13111191633













          • No offense, this is a great one-liner, but Bash's string substitution could probably do some magic w.r.t. the path change and would be easier.

            – 0xC0000022L
            Feb 8 '12 at 20:30











          • @STATUS_ACCESS_DENIED How so? The only string operation is to prepend /mnt to a path; you need no fancier string operation than concatenation.

            – Gilles
            Feb 8 '12 at 20:41











          • @Gilles: sorry, I was thinking more about your remark with the relative paths. For an exact "translation" of your example you are of course right.

            – 0xC0000022L
            Feb 8 '12 at 20:55



















          • No offense, this is a great one-liner, but Bash's string substitution could probably do some magic w.r.t. the path change and would be easier.

            – 0xC0000022L
            Feb 8 '12 at 20:30











          • @STATUS_ACCESS_DENIED How so? The only string operation is to prepend /mnt to a path; you need no fancier string operation than concatenation.

            – Gilles
            Feb 8 '12 at 20:41











          • @Gilles: sorry, I was thinking more about your remark with the relative paths. For an exact "translation" of your example you are of course right.

            – 0xC0000022L
            Feb 8 '12 at 20:55

















          No offense, this is a great one-liner, but Bash's string substitution could probably do some magic w.r.t. the path change and would be easier.

          – 0xC0000022L
          Feb 8 '12 at 20:30





          No offense, this is a great one-liner, but Bash's string substitution could probably do some magic w.r.t. the path change and would be easier.

          – 0xC0000022L
          Feb 8 '12 at 20:30













          @STATUS_ACCESS_DENIED How so? The only string operation is to prepend /mnt to a path; you need no fancier string operation than concatenation.

          – Gilles
          Feb 8 '12 at 20:41





          @STATUS_ACCESS_DENIED How so? The only string operation is to prepend /mnt to a path; you need no fancier string operation than concatenation.

          – Gilles
          Feb 8 '12 at 20:41













          @Gilles: sorry, I was thinking more about your remark with the relative paths. For an exact "translation" of your example you are of course right.

          – 0xC0000022L
          Feb 8 '12 at 20:55





          @Gilles: sorry, I was thinking more about your remark with the relative paths. For an exact "translation" of your example you are of course right.

          – 0xC0000022L
          Feb 8 '12 at 20:55













          13














          I know this is not exactly what the author is requesting but it seems they already have their answer so I'm adding this for others like me who stumble upon the question.



          The following should help if a more flexible solution is required such as having a bunch of broken symbolic links which can be fixed by replacing part of the symbolic link's targets.



          eg. After a change of username, to replace the old username with the new username in the target of many links, after the move had already been done. Create a script called replace-simlinks shown below:



          #!/bin/bash
          link=$1
          # grab the target of the old link
          target=$(readlink -- "$1")

          # replace the first occurrence of oldusername with newusername in the target string
          target=${target/oldusername/newusername}

          # Test the link creation
          echo ln -s -- "$target" "$link"

          # If the above echo shows the correct commands are being issued, then uncomment the following lines and run the command again
          #rm $link
          #ln -s "$target" "$link"


          and call it with the following command:



          find /home/newusername/ -lname '/home/oldusername/*' -exec ~/bin/replace-simlinks {} ;


          Hope this help somebody



          edit: Thanks Gilles for the kickstart on this script and the tip about using the symlinks script to make the links relative.






          share|improve this answer





















          • 1





            I find this solution better because it uses a string replace, which helps in cases where you have to change the name of a folder in the middle of the path. The solution is also quite easy to modify to perform more complex transformations if required.

            – Gallaecio
            Nov 29 '14 at 22:56











          • I'd recommend quoting the arguments to the string substitution, as that must be done to use slashes, e.g. for the path in the OP's question. target=${target/"/home"/"/mnt/home"} Very helpful, though. Thanks.

            – Walter Nissen
            Nov 29 '18 at 18:08


















          13














          I know this is not exactly what the author is requesting but it seems they already have their answer so I'm adding this for others like me who stumble upon the question.



          The following should help if a more flexible solution is required such as having a bunch of broken symbolic links which can be fixed by replacing part of the symbolic link's targets.



          eg. After a change of username, to replace the old username with the new username in the target of many links, after the move had already been done. Create a script called replace-simlinks shown below:



          #!/bin/bash
          link=$1
          # grab the target of the old link
          target=$(readlink -- "$1")

          # replace the first occurrence of oldusername with newusername in the target string
          target=${target/oldusername/newusername}

          # Test the link creation
          echo ln -s -- "$target" "$link"

          # If the above echo shows the correct commands are being issued, then uncomment the following lines and run the command again
          #rm $link
          #ln -s "$target" "$link"


          and call it with the following command:



          find /home/newusername/ -lname '/home/oldusername/*' -exec ~/bin/replace-simlinks {} ;


          Hope this help somebody



          edit: Thanks Gilles for the kickstart on this script and the tip about using the symlinks script to make the links relative.






          share|improve this answer





















          • 1





            I find this solution better because it uses a string replace, which helps in cases where you have to change the name of a folder in the middle of the path. The solution is also quite easy to modify to perform more complex transformations if required.

            – Gallaecio
            Nov 29 '14 at 22:56











          • I'd recommend quoting the arguments to the string substitution, as that must be done to use slashes, e.g. for the path in the OP's question. target=${target/"/home"/"/mnt/home"} Very helpful, though. Thanks.

            – Walter Nissen
            Nov 29 '18 at 18:08
















          13












          13








          13







          I know this is not exactly what the author is requesting but it seems they already have their answer so I'm adding this for others like me who stumble upon the question.



          The following should help if a more flexible solution is required such as having a bunch of broken symbolic links which can be fixed by replacing part of the symbolic link's targets.



          eg. After a change of username, to replace the old username with the new username in the target of many links, after the move had already been done. Create a script called replace-simlinks shown below:



          #!/bin/bash
          link=$1
          # grab the target of the old link
          target=$(readlink -- "$1")

          # replace the first occurrence of oldusername with newusername in the target string
          target=${target/oldusername/newusername}

          # Test the link creation
          echo ln -s -- "$target" "$link"

          # If the above echo shows the correct commands are being issued, then uncomment the following lines and run the command again
          #rm $link
          #ln -s "$target" "$link"


          and call it with the following command:



          find /home/newusername/ -lname '/home/oldusername/*' -exec ~/bin/replace-simlinks {} ;


          Hope this help somebody



          edit: Thanks Gilles for the kickstart on this script and the tip about using the symlinks script to make the links relative.






          share|improve this answer















          I know this is not exactly what the author is requesting but it seems they already have their answer so I'm adding this for others like me who stumble upon the question.



          The following should help if a more flexible solution is required such as having a bunch of broken symbolic links which can be fixed by replacing part of the symbolic link's targets.



          eg. After a change of username, to replace the old username with the new username in the target of many links, after the move had already been done. Create a script called replace-simlinks shown below:



          #!/bin/bash
          link=$1
          # grab the target of the old link
          target=$(readlink -- "$1")

          # replace the first occurrence of oldusername with newusername in the target string
          target=${target/oldusername/newusername}

          # Test the link creation
          echo ln -s -- "$target" "$link"

          # If the above echo shows the correct commands are being issued, then uncomment the following lines and run the command again
          #rm $link
          #ln -s "$target" "$link"


          and call it with the following command:



          find /home/newusername/ -lname '/home/oldusername/*' -exec ~/bin/replace-simlinks {} ;


          Hope this help somebody



          edit: Thanks Gilles for the kickstart on this script and the tip about using the symlinks script to make the links relative.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 20 mins ago

























          answered Dec 30 '11 at 16:07









          GerryGerry

          69168




          69168








          • 1





            I find this solution better because it uses a string replace, which helps in cases where you have to change the name of a folder in the middle of the path. The solution is also quite easy to modify to perform more complex transformations if required.

            – Gallaecio
            Nov 29 '14 at 22:56











          • I'd recommend quoting the arguments to the string substitution, as that must be done to use slashes, e.g. for the path in the OP's question. target=${target/"/home"/"/mnt/home"} Very helpful, though. Thanks.

            – Walter Nissen
            Nov 29 '18 at 18:08
















          • 1





            I find this solution better because it uses a string replace, which helps in cases where you have to change the name of a folder in the middle of the path. The solution is also quite easy to modify to perform more complex transformations if required.

            – Gallaecio
            Nov 29 '14 at 22:56











          • I'd recommend quoting the arguments to the string substitution, as that must be done to use slashes, e.g. for the path in the OP's question. target=${target/"/home"/"/mnt/home"} Very helpful, though. Thanks.

            – Walter Nissen
            Nov 29 '18 at 18:08










          1




          1





          I find this solution better because it uses a string replace, which helps in cases where you have to change the name of a folder in the middle of the path. The solution is also quite easy to modify to perform more complex transformations if required.

          – Gallaecio
          Nov 29 '14 at 22:56





          I find this solution better because it uses a string replace, which helps in cases where you have to change the name of a folder in the middle of the path. The solution is also quite easy to modify to perform more complex transformations if required.

          – Gallaecio
          Nov 29 '14 at 22:56













          I'd recommend quoting the arguments to the string substitution, as that must be done to use slashes, e.g. for the path in the OP's question. target=${target/"/home"/"/mnt/home"} Very helpful, though. Thanks.

          – Walter Nissen
          Nov 29 '18 at 18:08







          I'd recommend quoting the arguments to the string substitution, as that must be done to use slashes, e.g. for the path in the OP's question. target=${target/"/home"/"/mnt/home"} Very helpful, though. Thanks.

          – Walter Nissen
          Nov 29 '18 at 18:08













          3














          Create /home as a symlink to /mnt/home, and all the existing symlinks will be valid again.






          share|improve this answer



















          • 2





            Bind-mounting often tends to be less fragile than symlinks in scenarios where programs are aware of symlinks and act differently depending on the fact ...

            – 0xC0000022L
            Feb 8 '12 at 20:27
















          3














          Create /home as a symlink to /mnt/home, and all the existing symlinks will be valid again.






          share|improve this answer



















          • 2





            Bind-mounting often tends to be less fragile than symlinks in scenarios where programs are aware of symlinks and act differently depending on the fact ...

            – 0xC0000022L
            Feb 8 '12 at 20:27














          3












          3








          3







          Create /home as a symlink to /mnt/home, and all the existing symlinks will be valid again.






          share|improve this answer













          Create /home as a symlink to /mnt/home, and all the existing symlinks will be valid again.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 30 '11 at 20:05









          Keith ThompsonKeith Thompson

          14.4k43438




          14.4k43438








          • 2





            Bind-mounting often tends to be less fragile than symlinks in scenarios where programs are aware of symlinks and act differently depending on the fact ...

            – 0xC0000022L
            Feb 8 '12 at 20:27














          • 2





            Bind-mounting often tends to be less fragile than symlinks in scenarios where programs are aware of symlinks and act differently depending on the fact ...

            – 0xC0000022L
            Feb 8 '12 at 20:27








          2




          2





          Bind-mounting often tends to be less fragile than symlinks in scenarios where programs are aware of symlinks and act differently depending on the fact ...

          – 0xC0000022L
          Feb 8 '12 at 20:27





          Bind-mounting often tends to be less fragile than symlinks in scenarios where programs are aware of symlinks and act differently depending on the fact ...

          – 0xC0000022L
          Feb 8 '12 at 20:27





          protected by Community Oct 22 '14 at 11:11



          Thank you for your interest in this question.
          Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



          Would you like to answer one of these unanswered questions instead?



          Popular posts from this blog

          Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

          Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

          Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...