Suppose I have a file with many lines of the form

date time name some stuff

where every line may be different except for 'name', which is the same every time, and I want to remove 'name' from every line: is it possible to write a short bash script to achieve this?

  • Where does "recursive" come into play here? – Kusalananda Mar 5 '18 at 15:11

Gilles answer works but it will only remove name from standard output. If you want to remove name from the file itself then you need:

sed -i 's/name//' file


Why not simply :

sed 's/name//' file


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.