Routing the world

Routing & IT System Administration

Merge two files line by line and strip tabs

with 2 comments

If you want to merge two files line by line you can use the next code:

cat file1 | paste - | paste file2 -

This code will insert a tab between the lines for each file, if you need to strip the tab you can use:

tr -d ' \ 011'

So, the final result will be:

cat file1 | paste - | paste file2 - | tr -d ' \ 011'

Advertisements

Written by Root

September 22, 2009 at 10:46

Posted in Linux

Tagged with

2 Responses

Subscribe to comments with RSS.

  1. Why not paste -d" " file1 file2

    Hth

    aprendizdetodo

    November 2, 2010 at 13:20

    • I have not tested this command but as soon it will be needed I’ll do.

      Root

      November 3, 2010 at 17:17


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

%d bloggers like this: