1

I need to link the contents of a folder to my public_html folder.

If I use the following command:

ln -s ~/site/web/* ~/public_html/

The files are linked successfully but it doesn't link any hidden files i.e: .htaccess

If I use the following code:

ln -s ~/site/web/ ~/public_html/

It links the contents folder rather than just the files but it does link the hidden files within that folder. So my output is i.e: public_html/web/file1.html etc when it should be public_html/web/file1.html

Dan
  • 1,565
  • 3
  • 23
  • 43
  • have you tried with the full path (`ln -s /path/to/.hidden ~/public_html`) – treyBake Mar 23 '18 at 16:09
  • @ThisGuyHasTwoThumbs Thank you, that does work, so I've now created the command: ln -s ~/site/web/* ~/public_html/ && ln -s ~/site/web/.htaccess ~/public_html which does copy all the files. I'm a little worried though as later on there may be more hidden files so that would mean I would need to go through them manually. Is there not a simoe command that would do this? – Dan Mar 23 '18 at 16:40
  • no worries glad it helped you :) and not that I'm aware of :S maybe you can do something using `find -type f` but can't promise anything :/ sorry – treyBake Mar 23 '18 at 16:45
  • Me neither but as far as I can tell -s means symlink. – Dan Mar 23 '18 at 17:01

3 Answers3

3

So Thanks to @ThisGuyHasTwoThumbs I now have a code that does link all the files although, I have to manually tell it to link each hidden file.

Here's the code I used.

ln -s ~/site/web/* ~/public_html/ && ln -s ~/site/web/.htaccess ~/public_html

I will continue to look for a better way of doing it but for now it does work.

Dan
  • 1,565
  • 3
  • 23
  • 43
1

Use ln -s ~/site/web/.* ~/public_html/

ram
  • 11
  • 1
0

You could use an expression that match both, all normal files and directories and the hidden ones.

To achieve that, you could try:

ln -s ~/site/web/{*,.[aA-zZ]*} ~/public_html/

Use the following line if you only want to match hidden files and directories:

ln -s ~/site/web/{.[aA-zZ]*} ~/public_html/