0

I have text file with words like below.

motať sa
živiť sa
sabotovať
baviť sa
nasavať

And I want to delete word sa wrom each line. But I won't delete "sa" from word "sabotovať" or "nasavať". My final result will look like this:

motať
živiť
sabotovať
baviť
nasavať

I need this for ASPELL because ASPELL takes empty gap between words that "sa" is new word. I am using WINDOWS. Thank you.

user1844845
  • 281
  • 3
  • 7
  • 15

1 Answers1

0

You can (should) get sed from cygwin or other unix toolsets for your windows system(s)

To remove the word at the end of the line

sed 's/ sa$//' inputFile > outputFile

New question from comments (to remove a specific word)

sed 's/budeš//' inputFile > outputFile

Another new question from comments (to remove a word within a line - including at EOL)

sed 's/ sa//' inputFile > outputFile
KevinDTimm
  • 14,226
  • 3
  • 42
  • 60
  • And if i want delete word "budeš"? It don't work. How to do it? – user1844845 Apr 04 '13 at 14:30
  • #1 - you're welcome, feel free to upvote/accept - #2 - to delete the word you wish, just include it in place of the ' sa' – KevinDTimm Apr 04 '13 at 14:32
  • I know, but it don't work. And I also have word like "bude sa robiť" and "sa" from here don't disapear after your command. – user1844845 Apr 04 '13 at 14:39
  • Regex are very specific and so I solved only for the stated problem. If you change (correctly expand) the problem statement, then the solution will be better. My advice (after this edit) will be to apply my solution and then read up on regex - the things you want to do are simple - but regex can be VERY complex. – KevinDTimm Apr 04 '13 at 15:12
  • If you are going down the regex path like @KevinDTimm said, then check out: http://www.regexper.com It is a great tool to help you build regular expressions. – arajek Apr 04 '13 at 18:53