Re: mth part of n parts

"Daniel Goldman [email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
Not exactly clear what "equal parts" means. It seems you mean "equal 
number of lines". If so, the only tricky part is calculating m (first 
line to print) and n (last line to print). Then, as previous posters 
suggested, you run:

sed -n "$m,$n p" infile

If you are not printing entire lines, then you would need to explain 
more exactly what "equal parts" means, perhaps with an example.

BTW - Suppose you had 99 lines and divided into 10 parts. Which part has 
the 9 lines (the others having 10 lines)? I guess it's an arbitrary 
decision.

Daniel

On 4/3/2015 12:24 PM, Jim Hill [email protected] [sed-users] wrote:
>> sed -n "$((${i}*${bs})),$((${i}*${bs}+${bs}-1))p"
>
> I think you don't need the explicit substitution
>
>      sed -n $((i*bs-bs+1)),$((i*bs))p
>
> (I think op wants 1-based indexing rather than 0-based offsets)
>
> or is that a bashism?
>
>
> ------------------------------------
> Posted by: Jim Hill <[email protected]>
> ------------------------------------
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.