Hi all,
I have a list of servers in a file test
I have used awk to print the particular column.I need to configure 100 servers but the description has a space between .Hence the configuration file is not created properly
#cat test
host1,10.0.0.1,AD server
host2,10.0.0.2,File server
host3,10.0.0.3,Print Server
The script is
# vim test.sh
for i in $(cat test);do
h=$(grep $i test | awk -F "," '{print $1}')
P=$(grep $i test | awk -F "," '{print $2}')
S=$(grep $i test | awk -F "," '{print $3}')
echo $S,$P,$H >> ip
#echo define host{ >> hosts.cfg
# echo -e ' \t ' "use" ' \t ' ' \t ' hoststatus >> hosts.cfg
# echo -e ' \t ' "host_name" ' \t ' $h >> hosts.cfg
# echo -e ' \t ' "alias" ' \t ' $S >> hosts.cfg
# echo -e ' \t ' "address" ' \t ' $P >> hosts.cfg
# echo -e ' \t ' "hostgroups" ' \t ' monitor >> hosts.cfg
#echo } >> hosts.cfg
done
the output is
#cat test
AD server
File server
Print Server,10.0.0.1
10.0.0.2
10.0.0.3,host1
host2
host3
Print Server,10.0.0.3,host3
Hence I used sed to replace the space which some character
# cat test
host1,10.0.0.1,AD;server
host2,10.0.0.2,File;server
host3,10.0.0.3,Print;Server
#sh test.sh
the output is fine .Why is the space between the two words not printed properly irrespective of me specifing the delimiter :(.Should I use LFS="/n" or some parameter to fix this issue
Need your expertise for the same