0

I have in.txt file with over 10000 line, some text in this file between bract like ( this text ) and the text out the bract not export, i want to export all text between ( ) to out.txt, but provided that under 140 letters if the letters over 140 letters don't export it, and every text exported in new line out.txt . I wan't script to do that in ubuntu, and the text written by non latin letters (utf-8). Regards

0

Assuming that the text between parentheses can't itself contain parentheses, and that you mean under or equal to 140 characters, try

grep -Po '(?<=\().{1,140}?(?=\))' in.txt > out.txt
  • Thank you steeldriver, it's work, Best Regards. – silver Mar 17 at 20:18
  • Please can you change this code or give me new code to remove any line containt one or more of this symbole ( ? , [ , ] , - ). – silver Mar 18 at 1:45
  • @silver you can try replacing .{1,140} by [^[\]-]{1,140} – steeldriver Mar 18 at 16:52
  • to remove any line containt symbol: grep -v '[\:\?*\«\»\،\-]' in.txt > out.txt – silver Mar 19 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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