shell parse csv file, assign fields to variable and print it in multiple columns
<p>Im trying to curl a csv file and parse it based on their property and print it back by using variable names.</p>

<p><strong>File 1:</strong></p>

<pre><code>10.0.0.1,gateway,name_of_device
10.2.4.5,server,name_of_device
10.3.5.6,PC,name_of_device
</code></pre>

<p>My script below,</p>

<pre><code>#!/bin/sh

input=$(curl http://example.com/1.txt)

ip=$(echo "$input" | awk -F ',' '{print $1}')
type=$(echo "$input" | awk -F ',' '{print $2}')
name=$(echo "$input" | awk -F ',' '{print $3}')

echo "$ip $type $name" 
</code></pre>

<p>This prints,</p>

<pre><code>10.0.0.1
10.2.4.5
10.3.5.6
gateway
server
PC
name_of_device
name_of_device
name_of_device
</code></pre>

<p>but the expected output should be like,</p>

<pre><code>10.0.0.1 gateway name_of_device
10.2.4.5 server name_of_device
10.3.5.6 PC name_of_device
</code></pre>

<p>Tried different options like,</p>

<p>assigning output to another variable and echo'ing it,</p>

<pre><code># output="$source_ip $tag_text"
# echo -e $output
</code></pre>

<p>printf statements:</p>

<pre><code># printf "%-20s | %-20s" "$source_ip" "$tag_text"


# printf "$source_ip" "$tag_text"
</code></pre>