DevOpsnipp.com © 2019

Featured snippets are MIT license

Terms Of Use

Privacy Policy

Gears & Masters

  • Facebook Social Icon

Merging columns in file in Unix

Merging columns in file in Unix

37

Votes

#!/bin/sh
length=`wc -l $1 | awk '{print $1}'`
count=1
[ -f $3 ] && echo "Optionally removing $3" && rm -i $3
while [ "$count" -le "$length" ] ; do
      a=`head -$count $1 | tail -1`
      b=`head -$count $2 | tail -1`
      echo "$a      $b" >> $3
      count=`expr $count + 1`
done

Vote Here

You must earn at least 1 vote on your snippets to be allowed to vote