Ler cada linha de arquivo em Shell Script

Imprimir cada linha

while read line; do
  echo $line
done < /etc/resolv.conf

Imprimir cada coluna separadamente

while read c1 c2; do
  echo coluna1: $c1 coluna2: $c2
done < /etc/resolv.conf

Imprimir colunas especificas definindo separador de campos

while IFS=: read c1 c2 c3 c4 c5 c6 c7; do
  echo $c1 $c7;
done < /etc/passwd
Advertisements

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s