0

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/

Mohammad AL-Rawabdeh
  • 1,612
  • 12
  • 33
  • 54
  • 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

2 Answers2

6
sed -ie 's/db\/fs-type//g' FILENAME
or cat FILENAME | sed -e 's/db\/fs-type//g'

howto: http://www.grymoire.com/Unix/Sed.html

bindbn
  • 5,211
  • 2
  • 26
  • 24
0

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: http://www.cs.hmc.edu/tech_docs/qref/sed.html

An example a little more specific to your situation: http://www.computing.net/answers/unix/replace-a-complex-string-using-sed/5811.html

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

Johnnie Odom
  • 1,199
  • 7
  • 10