Cy_Pqa
1
Hello,
Is there a way to filerter data from a text file as shown below to a Column
e.g.
hostname nfsmount as two separate column. Currently I could get hostname and the mount is appearing below.. using this script
#! /bin/bash
for i in `cat fqdn.txt`
do
echo "$i ............ " >> fstab.txt
ssh username@$i "cat /etc/fstab |column -t | grep 'bur-filer*'" >> fstab.t xt
done
hostname.host1.com ............
bur-filer2:/vol/vol1 /mnt/bur-filer2/vol1 nfs rw,defaults 0
hostname.host2.com ............
bur-filer2:/vol/vol1 /mnt/bur-filer2/vol1 nfs rw,defaults 0
Thank You
You have shown the data you don't want, but haven't shown the data you do want, so I don't understand what you want your output to look like.
You can simplify your code as such:
#! /bin/bash
while read i
do
echo "$i ............ "
ssh -n username@$i "< /etc/fstab column -t | grep 'bur-filer.*'"
done < fqdn.txt > fstab.txt
Cy_Pqa
3
Thank you for your reply.
I am looking for the output like this
Hostname Mount Points
hostname.host1.com bur-filer2:/vol/vol1 /mnt/bur-filer2/vol1
hostname.host2.com bur-filer2:/vol/vol1 /mnt/bur-filer2/vol1
Instead of showing like this.
hostname.host1.com ............
bur-filer2:/vol/vol1 /mnt/bur-filer2/vol1 nfs rw,defaults 0
hostname.host2.com ............
bur-filer2:/vol/vol1 /mnt/bur-filer2/vol1 nfs rw,defaults 0
Appreciate your help
Thank you
RudiC
4
If your system allows for it, try to suppress echo's new line char:
echo -n "$i"
or use printf
omitting the \n
in the format string.