-2

I have a list of words in a text file, one per line.

I would like to make a symbolic link for each of for each word in the text file.

For example, lets say real directory is /stuff/testing/original

Text file is of format

word1
word2
word3

I want to have /stuff/testing/word1, /stuff/testing/word2, /stuff/testing/word3, all being a symlink to /stuff/testing/original

What is the best way to accomplish this?

0

This is a BASH command (it won't work in TCSH or KSH) :

for NAME in $( < cat /path/to/listfile ) ; do ln -s /stuff/testing/original "${NAME}" ; done
0

Similar to the for loop above, you could use a while loop to read the file:

while read NAME ; do ln -s /stuff/testing/original /stuff/testing/$NAME ; done < /stuff/testing/original

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.