Using sed to insert text at the beginning of each line

62,968
sed 's/^/rm -rf /' filename

EDIT

Xargs would be simpler way to delete all of the files listed in another file

xargs -a filename rm -rf
Share:
62,968
THE DOCTOR
Author by

THE DOCTOR

I am a Time-Lord from the planet Gallifrey and the last remaining survivor of my race. I have regenerated several times now as follows: Database Developer -> QA Engineer -> Software Engineer -> Network/Systems Engineer -> Director of IT & Network Engineering.

Updated on March 19, 2020

Comments

  • THE DOCTOR
    THE DOCTOR about 4 years

    How would one go about using sed in order to insert

    rm -rf
    

    at the start of each line of a file?

  • mikerobi
    mikerobi over 13 years
    @Dennis Williamson, nice tip, I pretty much only ever call xargs, when I'm piping in output from another program, so I would never have bothered figuring that out.