Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a list of records in a file as in below example

word_word1
word_word1_acc
word_word2_acc
word_word3_acc
word_word4

I need to remove only word_word1_acc line in the file as it is only a repetition of the first line. As in the example, I have multiple fields in each line. How can I do this?

share|improve this question

1 Answer 1

If this is indeed the exact file that you want to change, you can do

sed -i.old -e 's/word_word1_//' /path/to/filename

to change the file in-place. You can skip the -i... part to see what sed would do.

(The -i option tells sed to write a backup file of your source and append a .old to the filename)

share|improve this answer

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.