Avatar of glenwdri
glenwdri
Flag for Afghanistan asked on

I need to insert a character at the beginning of every line in a txt doc

I need to insert a > character at the beginning of every line in a txt doc, how do I do this
ProgrammingEditors IDEsAlgorithms

Avatar of undefined
Last Comment
glenwdri

8/22/2022 - Mon
2sq

If you have excel, you can copy the text file to excel and paste. Move the entire selected column over a cell and then place what you want ahead of it in the first cell you have just left yourself. Copy the entire thing and past it back into a text document.
glenwdri

ASKER
this has to be done on about 200 files at a time and more than once hence the desire for sed to do it.
a1j

sed --in-place=.bak s/^/character/ filename.txt

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
a1j

If character is > then

sed --in-place=.bak 's/^/>/' filename.txt

Ir you can do it within find script for many files

fine /dir -type f -name "*.txt" -exec sed --in-place=.bak 's/^/>/' {} \;
a1j

find instead of fine (typo)
ASKER CERTIFIED SOLUTION
glenwdri

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
glenwdri

ASKER
I found it myself
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.