libera/#maemo/ Wednesday, 2024-07-31

sunshavi_Hi. I am filtering the output of n9Export21:19
sunshavi_I have this file https://termbin.com/pesl21:19
sunshavi_after searching the best tools for filtering multiline sms's are sed and awk21:19
sunshavi_the most promising option is "sed -n '/987654321/,/^[^ ]*/p' filesmsN9" But is not working as expected21:19
sunshavi_any idea on how to filter multiline sms's for an specific number?21:20
KotCzarnyif 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 possible21:24
joergsunshavi_: what's the goal?22:38
joergthe sed command doesn't really make sense to me, probably my fault22:39
joerghttps://www.pement.org/sed/sed1line.txt22:41
sunshavi_the goal is filtering multiline sms's for an specific phone number. I am trying awk now22:42
joergyou didn't provide more info than you did initially22:49
joergwhat's wrong with grep?22:50
joergI mean, "search for a line with a particular pattern" is literally the genuine definition of what grep is supposed to do22:51
sunshavi_grep is useful for matching lines not multiple lines22:52
joergheck, where did you tell something about "multiple lines"?22:53
sunshavi_multiline = multiple lines.22:53
joergwell, either you can specify your exact requirements in plain text, or you find a matching sed command in the link I provided22: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 below22: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 CCC22:57
joerg sed -e '/./{H;$!d;}' -e 'x;/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d22:57
joerg gsed '/./{H;$!d;};x;/AAA\|BBB\|CCC/b;d'         # GNU sed only22: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.html22: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' file22:59
sunshavi_But. It is like alien language for me23:00
joergsorry, I still don't know what are the ... nevermind23:01
sunshavi_have You saw the shared termbin?. It has data just for two phone numbers23:02
joergsee, you provide a file without explaining its satructure, then you ask for a command to act on it's structure23:07
joergI 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 file23:11
joergO guess "AAA" would be the number23:11
joergno idea how your paragraps are delimuted23:11
sunshavi_delimiter is explained here https://github.com/merlin1991/Harmattan-SMS-Boat.git23:28
joergtoo much reading23:49
joergsorry23:49
* joerg can't help it :-D23: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/!