Please become accustomed to provide decent context info of your problem, like OS, shell, related environment, preferred tools, representative input sample, desired output, and the logics connecting the two.
Is this a homework / classroom problem? Homework and coursework questions can only be posted in
this forum under
special homework rules.
If this is NOT homework, please show us the background of the problem, e.g. the company branch / project you work for, or the type of research.
Thank You.
The UNIX and Linux Forums.