How would one go about using sed in order to insert
rm -rf
at the start of each line of a file?
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
Sometimes you have to go with the original method using sed, especially when you want to do things like
csf -d ipaddr.
xargs
doesn't seem to like the output created by some commands and gives up after the first line. ie:
sed 's/^/csf -d /' hacks >>hacks.sh
You should use
#if you want to add only to each line matching string
sed 's/\(^matchingstring.*$\)/"yourtext" \1/' myfile.txt
#if you want to add to each line
sed 's/^/"yourtext"/' myfile.text