-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

2 Answers 2

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .