WebHosting

Thursday, October 3, 2013

Display two files side by side in linux

Have you ever needed to display cat content of two files side by side on terminal, if yes you are right place :)

You have following options :



1. Vimdiff :
        Edit two, three or four versions of a file with Vim and show differences, just play with 'man vimdiff' for more options.

Eg : vimdiff file1 file2

2. Paste :
       Merge lines of files, go for 'man paste' for more options.

Eg : paste file1 file2

3. Pr :
     Convert text files for printing, do 'man pr' for more detail.

Eg : pr -m -t -W 100 brl gndcfile
     
  • -m, --merge     
               Print all files in parallel, one in each column,
  • -t, --omit-header  
               Omit page headers and trailers
  • -w, --width=PAGE_WIDTH
               Number of characters per page

4. sdiff :
          side-by-side merge of file differences, do 'man sdiff' for more detail

Eg: sdiff file1 file2

5. Using awk command:

Eg:

awk 'BEGIN{print "Column1\tColumn2"} {getline a < "file2";printf "%-40s\t%s\n",$0,a}' file1

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

How to Auto-Terminate Frozen and Hung Apps in Windows

We have all been there. You are in the middle of an important project or a gaming session, and suddenly, your screen freezes. The dreaded ...