Advertisement
lincruste

multiple symlinks

Dec 30th, 2013
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.66 KB | None | 0 0
  1. Let's say you have a /target  directory containing
  2.  
  3. Code:
  4. pic1.jpg
  5. pic2.jpg
  6. pic3.jpg
  7. pic4.jpg
  8. ...
  9.  
  10. and you want to create some links in /linksource
  11.  
  12. Code:
  13. lnkpic1 pointing to pic1.jpg
  14. lnkpic2 pointing to pic2.jpg
  15. lnkpic3 pointing to pic3.jpg
  16. lnkpic4 pointing to pic4.jpg
  17. ...
  18.  
  19. to create those lnkpic* link you can for example :
  20. just
  21.  
  22.  
  23. Code:
  24. cd /linksource
  25. for i in /target/pic*.jpg
  26. do
  27. t=${i##*/}
  28. ln -s "$i" lnk"${t%.*}"
  29. done
  30.  
  31. If what you want is something else for example, you want /linksource to be a link to /target so that if someone do cd /linksource, he goes to /target and can see the pic*.jpg,
  32. then
  33.  
  34. Code:
  35. ln -s /target /linksource
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement