user2707590
user2707590

Reputation: 1126

Bash script to create symlinks

I am trying to create a script which would create symlinks from a folder 1 level up and i am using as follows:

symlinks.sh

ln -s '../config/environments' > 'environments'
ln -s '../config/init' > 'init'

environments is a folder and init is a file.

and when i go to the folder where symlinks.sh is and execute ./symlinks.sh, its creating 4 files which are:

  1. environments
  2. environments?
  3. init
  4. init?

I also tried:

ln -s '../config/environments' .
ln -s '../config/init' .

but with this one, init is created in the current folder and environments goes to folder ../config/environments/environments

Can someone help me please?

Upvotes: 1

Views: 2023

Answers (1)

Alex
Alex

Reputation: 178

It's because you are redirecting the output ">". You don't need to do that with ln, it will automatically create a symlink in the current directory if you use:

ln -s "../config/environments" 
ln -s "../config/init"

Upvotes: 3

Related Questions