0

I have a given shell script, to read file in the same directory:

#!/bin/bash

file="server.info"
while IFS= read -r server_ip env_type; do
        echo "$server_ip and packege type $env_type"    
done

server.info file looks like:

209.97.131.182 rpm
209.97.131.185 deb
209.97.131.189 rpm

But, while I run bash script it does not produce any results and stay blank

  • You're not actually reading _from the file_, because while you put the filename in a variable you never use that variable. Put `<"$file"` after the `done` – Charles Duffy Nov 18 '22 at 17:21
  • Also, you probably don't want `IFS=` here. IFS is what tells it which characters can be used to separate the two fields, so you _at least_ want it to contain a space when the fields are space-separated. – Charles Duffy Nov 18 '22 at 17:25

0 Answers0