How to use IFS to get output of range in comma separator in bash?

I would like to have output like below

ns2.com,ns3.com,ns4.com,ns5.com,ns6.com,ns7.com,ns8.com,ns9.com,ns10.com,

Open in new window


which I am able to get from below command in bash

$printf '%s,' ns{2..10}.com
ns2.com,ns3.com,ns4.com,ns5.com,ns6.com,ns7.com,ns8.com,ns9.com,ns10.com,

Open in new window


I am wondering if I can get something like this using IFS (Internal Field Separator) in bash

something like
IFS=, ns{2..10}.com

Open in new window


which obviously doesn't work. Appreciate any suggestion :-)
beer9Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nociSoftware EngineerCommented:
IFS means Input Field Separator and can be used for splitting fields...
Like so:
 printf '%s,' ns{2..10}.com | (IFS=, read a b c d e f ; echo $a / $b / $c / $d / $e / $f )

Yielding:
ns2.com / ns3.com / ns4.com / ns5.com / ns6.com / ns7.com,ns8.com,ns9.com,ns10.com,

So what are you trying to accomplish exactly?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
woolmilkporcCommented:
Usually shell builtins do not take IFS/OFS settings into account, at least bash's brace expansion definitely doesn't.

In order to avoid the comma at the end you could try this:

echo  ns{2..10}.com | tr " " ","

As I said, no chance with IFS, unfortunately!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.