| sunshavi_ | Hi. I am filtering the output of n9Export | 21:19 |
|---|---|---|
| sunshavi_ | I have this file https://termbin.com/pesl | 21:19 |
| sunshavi_ | after searching the best tools for filtering multiline sms's are sed and awk | 21:19 |
| sunshavi_ | the most promising option is "sed -n '/987654321/,/^[^ ]*/p' filesmsN9" But is not working as expected | 21:19 |
| sunshavi_ | any idea on how to filter multiline sms's for an specific number? | 21:20 |
| KotCzarny | if simple approach becomes complicated, i usually switch to some scripting lang (perl/php/python/etc) | 21:21 |
| sunshavi_ | Yes. oneline would be awesome. I still think It could be possible | 21:24 |
| joerg | sunshavi_: what's the goal? | 22:38 |
| joerg | the sed command doesn't really make sense to me, probably my fault | 22:39 |
| joerg | https://www.pement.org/sed/sed1line.txt | 22:41 |
| sunshavi_ | the goal is filtering multiline sms's for an specific phone number. I am trying awk now | 22:42 |
| joerg | you didn't provide more info than you did initially | 22:49 |
| joerg | what's wrong with grep? | 22:50 |
| joerg | I mean, "search for a line with a particular pattern" is literally the genuine definition of what grep is supposed to do | 22:51 |
| sunshavi_ | grep is useful for matching lines not multiple lines | 22:52 |
| joerg | heck, where did you tell something about "multiple lines"? | 22:53 |
| sunshavi_ | multiline = multiple lines. | 22:53 |
| joerg | well, either you can specify your exact requirements in plain text, or you find a matching sed command in the link I provided | 22:54 |
| joerg | # print paragraph if it contains AAA (blank lines separate paragraphs) | 22:57 |
| joerg | # HHsed v1.5 must insert a 'G;' after 'x;' in the next 3 scripts below | 22:57 |
| joerg | sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;' | 22:57 |
| joerg | # print paragraph if it contains AAA and BBB and CCC (in any order) | 22:57 |
| joerg | sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;/BBB/!d;/CCC/!d' | 22:57 |
| joerg | # print paragraph if it contains AAA or BBB or CCC | 22:57 |
| joerg | sed -e '/./{H;$!d;}' -e 'x;/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d | 22:57 |
| joerg | gsed '/./{H;$!d;};x;/AAA\|BBB\|CCC/b;d' # GNU sed only | 22:57 |
| sunshavi_ | I am trying to adapt this one https://www.unix.com/unix-for-dummies-questions-and-answers/143204-extract-consecutive-lines-begin-character.html | 22:58 |
| joerg | # insert a blank line above every line which matches "regex" | 22:58 |
| joerg | sed '/regex/{x;p;x;}' | 22:58 |
| sunshavi_ | awk '/^\$/{if(!p)x=$0;p++}!/^\$/{p=0}p==2{print x}p>1' file | 22:59 |
| sunshavi_ | But. It is like alien language for me | 23:00 |
| joerg | sorry, I still don't know what are the ... nevermind | 23:01 |
| sunshavi_ | have You saw the shared termbin?. It has data just for two phone numbers | 23:02 |
| joerg | see, you provide a file without explaining its satructure, then you ask for a command to act on it's structure | 23:07 |
| joerg | I provided "# print paragraph if it contains AAA (blank lines separate paragraphs)" and probably you need to actually do the tedious task to define what's "AAA" in your case, and what is the "blank line" flag in your file | 23:11 |
| joerg | O guess "AAA" would be the number | 23:11 |
| joerg | no idea how your paragraps are delimuted | 23:11 |
| sunshavi_ | delimiter is explained here https://github.com/merlin1991/Harmattan-SMS-Boat.git | 23:28 |
| joerg | too much reading | 23:49 |
| joerg | sorry | 23:49 |
| * joerg can't help it :-D | 23:54 | |
| joerg | >> If the SMSText contains newlines a space is added after the newline --> lines starting with a space are a continuation of the last sms text.<< | 23:55 |
Generated by irclog2html.py 2.17.0 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!