I have a list like this.
Bob
Jim
Steve
Is there a way in bash to turn that into a list like this?
<a href="http://example.com/Bob"> Bob
<a href="http://example.com/Jim"> Jim
<a href="http://example.com/Steve"> Steve
This should work fine:
#/usr/bin/env bash
while read n; do
echo "<a href=\"http://example.com/${n}\">${n}</a>"
done < ${1}
If you made that a script, then you would call it with ./scriptname.sh filename.txt
and it just prints it to the console. (Note: I extrapolated your question to include a </a>
as well.)
list=("Bob", "Jim", "Steve")
) then you could dofor i in "${list[@]}"; do echo <a href="http://example.com/${i}">${i}</a>; done
.