Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

2 Answers

up vote 6 down vote accepted
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

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
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

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.