Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using sed to insert text at the beginning of each line

Tags:

How would one go about using sed in order to insert

rm -rf 

at the start of each line of a file?

like image 487
THE DOCTOR Avatar asked Nov 02 '10 17:11

THE DOCTOR


People also ask

How do you add a first line in sed?

Use sed 's insert ( i ) option which will insert the text in the preceding line.


1 Answers

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 
like image 168
mikerobi Avatar answered Oct 15 '22 12:10

mikerobi