Ksh читання файла по рядках

Приклад того, як за допомогою ksh можна розібрати текстовий файл з даними

#!/bin/ksh
file="/path/to/file.txt"
# while loop
while read line
do
# display line or do somthing on $line
echo "$line"
done <"$file"

Наприклад у нас є текстовий файл з певними даними:

google.com|74.125.53.100
yandex.ru|87.250.251.11
meta.ua|194.0.131.18

Ми хочем його розібрати і отримати окремо хост і ip-адресу

#!/bin/ksh# set the Internal Field Separator to a pipe symbol
IFS='|'# file name
file=/tmp/domains.txt
# use while loop to read domain and ip
while read domain ip
do
print "$domain has address $ip"
done <"$file"



coded by nessus