Question

I am trying to mimic the -i flag in sed when -i throws an error, saying it is not available. Evidently the server I connected to has an ancient version of sed or a version without the -i flag.

How would one mimic the edit in place -i of sed if it were unavailable?

Was it helpful?

Solution

Use ed:

printf ',s/PATTERN/REPLACE/g\nw\nq\n' | ed -s your_file.txt
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top