Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i want to delete something from each line of file for example :-

i have the following path in file : /var/lib/svn/repos/b1me/products/payone/generic/code/core/db/fs-type /var/lib/svn/repos/b1me/products/payone/generic/code/fees/db/fs-type /var/lib/svn/repos/b1me/products/payone/generic/code/merchantserver/db/fs-type

i want to do something to become /var/lib/svn/repos/b1me/products/payone/generic/code/core/ /var/lib/svn/repos/b1me/products/payone/generic/code/fees/ /var/lib/svn/repos/b1me/products/payone/generic/code/merchantserver/

share|improve this question
You need to be more specific. Are these lines of data in a file, or a list of files, or what? If you give a bit of context, it'll help get answers. – Cylindric Sep 21 '10 at 13:27
Do you want to delete a string or you want to perform a substitution? – jscott Sep 21 '10 at 13:28
up vote 6 down vote accepted
sed -ie 's/db\/fs-type//g' FILENAME
or cat FILENAME | sed -e 's/db\/fs-type//g'


share|improve this answer
i try two command ... command cat FILENAME | sed -e 's/db\/fs-type//g' work :) thank you :) – Mohammad AL-Rawabdeh Sep 21 '10 at 13:56

It sounds like what you want to do is simple substitution, and for that the use of a tool like sed with simple regular expression matching is the classical means of achieving your goal. A simple search turns up a ton of links, but here are two that should get you started on your way:

Generally using sed for string replacement in a file:

An example a little more specific to your situation:

This is one of the most common sorts of problems to solve, and solutions are fairly ubiquitous in the Linux community.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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