Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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=""> Bob
  • <a href=""> Jim
  • <a href=""> Steve
share|improve this question
Where is the list coming from? That is probably the best way to start and give you some ideas. If it is a bash array, then use of awk or sed is probably unnecessary. If it's just an array (i.e. list=("Bob", "Jim", "Steve")) then you could do for i in "${list[@]}"; do echo <a href="${i}">${i}</a>; done. – nerdwaller Aug 5 '13 at 21:07
It's just a text file. – 13throwaway Aug 5 '13 at 21:07
Each on its own line? – nerdwaller Aug 5 '13 at 21:08
Yes, each on it's own line. – 13throwaway Aug 5 '13 at 21:09
up vote 1 down vote accepted

This should work fine:

#/usr/bin/env bash

while read n; do
    echo "<a href=\"${n}\">${n}</a>"
done < ${1}

If you made that a script, then you would call it with ./ filename.txt and it just prints it to the console. (Note: I extrapolated your question to include a </a> as well.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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