The Paste Unix Command

Today I had to process thousands of files containing two lines, the first with the start time of a process and the second line with the time of termination of the process. Of course, maybe it would be a single log file where all the records are in a file rather than per process, but the process is inherited and is designed to work in this way. The problem is that I need automating the management of this information and it is most useful if I have it in a single line, because I will take the hours of beginning and end. For this there are several tools, but today I speak of the paste command, which is usually quite unknown and can be very powerful to together text horizontally.

This is an example of my original file;

 
moon:/supro_downloads/logs=> cat Supro_00203.log
Time start: 160216:1236
Time end: 160216:1236

And this would be the result of doing a simple paste;

 
moon:/supro_downloads/logs=> paste -s Supro_00203.log
Time start: 160216:1236 Time end: 160216:1236

In my case I am carrying a general file and then automate their treatment;

 
moon:/supro_downloads/logs=> paste -s Supro_00203.log  >> All_Times.log

HTH – Antonio NAVARRO

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s