FG
💻 Software

How do I add a prefix/suffix to each line of a file?

Fresh5 days ago
Mar 15, 202624152 views
Confidence Score0%
0%

Problem

For example, file1 contains: Now I want to add a prefix "file1:" to each line: How can I do that in one command line? I'm using Bash. BTW, the leading space must be preserved, so the Bash built-in read line doesn't work for me.

Error Output

entry1:value1
entry2:value2
entry3:value3

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How do I add a prefix/suffix to each line of a file?

Low Risk

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment