[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Little question grep



That strikes me as being just a touch too complex for grep.  It may well
be doable, but you'll probably have an easier time using AWK (possibly not
what you wanted to hear, but it's well worth learning).  The object of the
game would be to count the number of signs on each line and print only
those with the specified number.  Then in a shell script (my preferred
poison is ksh) set up a loop like so:

#Not guaranteed to be syntactically correct
for ((i=5; i<=10; i++)); do
  awk -f ctsign.awk N=$i biglist.txt >${i}signs.txt
  done

Or one can use such scripting languages as Perl or Python to do the whole
job.

Hope it helps...

--------------------------|
John L. Ries              |
Salford Systems           |
Phone: (619)543-8880 x107 |
or     (435)867-8885      |
--------------------------|


On Sun, 8 Jan 2017, Hans wrote:

>
> Hi all,
>
>
>
> I have a little problem with using grep.
>
>
>
> The problem:
>
>
>
> I have a wordlist with 3,5 Mio words in ASCII. No I want filter out all
> words with 5,6, 7, 8, 9 and 10 signs in seperate lists. The wordlist
> contains all sort of signs, like alphanumeric, control signs like "^", "]"
> and others.
>
> So it must be same, whatever sign grep reads. I found this:
>
>
>
> grep -o -w -E '^[[:alnum:]]{5}' file1
>
>
>
> But it looks like it is only grepping text. I read the manual of grep, and I
> see, there are more options to chose. But I did not completely understand,
> if I have to chose every option in addition or if is there an option,which
> covers every kind of sign.
>
>
>
> Would be nice, if someone could make this a little bit brighter for me.
>
>
>
> Thank you for any hints.
>
>
>
> Best regards
>
>
>
> Hans
>
>
>
>
>
>
>


Reply to: