Add Prefix or Suffix to Lines
Add a prefix and a suffix to every line of text, with optional line numbers, a {n} placeholder for the line number and empty lines left alone.
Free · No sign-up · Your inputs stay in your browser
Input
Add a prefix or suffix to every line
Output
Result
89 characters
The shell versions: sed 's/^/prefix/' adds a prefix and sed 's/$/suffix/' a suffix, and awk '{print "prefix" $0 "suffix"}' does both. Turning a list of hosts into commands this way is quick; for anything you will run twice, a loop in a script is easier to review.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
Turning lists into commands
A list of hosts becomes ssh commands, a list of files becomes chmod lines, a list of ids becomes SQL values, a block of text becomes a quote or commented-out code. For anything you will run more than once, a loop in a script is easier to review than generated commands.
The shell equivalents
sed 's/^/PREFIX/' adds a prefix and sed 's/$/SUFFIX/' a suffix; awk can do both in one pass and use NR for the line number.