1

I have 2 files namely f1 and f2. File f1 keeps getting new output periodically in the form

$cat f1
a
b
c

After "x" seconds

$cat f1
e
f
g

After "2x" seconds

$cat f1
    h
    i
    j

and so on.

I want to horizontally concatenate all the outputs in f1 in to a new file f2 which after "2x" seconds will have the output and it will continue in this fashion

$cat f2
a  e  h
b  f  i
c  g  j

How can I achieve this in linux using "paste" and crontab? Thanks.

0

You can't -- cron is not accurate enough for that.

Instead I would suggest replacing f1 with a named pipe, attaching a reader process to that named pipe. That process would read for exactly x seconds, copying what is read into a file with a predictable, sequentially incrementing name. You could then use cron to periodically paste any such files together into f2, removing the ones you have already processed.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.