- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: print field seperators
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2009 05:24 AM
тАО04-16-2009 05:24 AM
I have setup an array in a config file and what to use it in two ways - here is the array:
ECM_PORT[1]=443
ECM_PORT[2]=7943
ECM_PORT[3]=7843
ECM_PORT[4]=7080
ECM_PORT[5]=7090
the first is to print the array on one line field seperator being a "+"
# echo ${ECM_PORT[*]}
443 7943 7843 7080 7090
so I want to replace the white space with:
443+7943+7843+7080+7090
the string is to be executed in a command and the array will contain a different number of elements depending on the environment being configured.
The second function is pretty straight forward and can workout myself :-)
Thanks
Chris.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2009 05:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2009 06:14 AM
тАО04-16-2009 06:14 AM
Re: print field seperators
I was playing around with on something like:
echo ${ECM_PORT[*]} |awk 'BEGIN{RS="\n";ORS="+"};{ for ( i = NF; i > 0; i = i - 1 ) print $i}'
which prints:
7090+7080+7843+7943+443+
this obviously prints backwards and leaves a "+" at the end with no carriage return.
my way needs a bit more work to print in order.
Thanks anyway james - your help is always appreciated.
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2009 07:54 AM
тАО04-16-2009 07:54 AM
Re: print field seperators
echo ${ECM_PORT[*]} |awk '{ for ( i = 1; i <= NF; i = i + 1 )
if ( i == 1 ) out = $i
else out = out"+"$i
print out}'
443+7943+7843+7080+7090
Thanks again
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2009 08:23 AM
тАО04-16-2009 08:23 AM
Re: print field seperators
If you prefer your 'awk', then:
# echo "${ECM_PORT[*]}"|awk '{for (i=1;i
...or:
# echo "${ECM_PORT[*]}"|awk '{for (i=1;i
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2009 09:10 PM
тАО04-16-2009 09:10 PM
Re: print field seperators
Why is everyone working so hard? :-)
IFS_SAVE=$IFS
IFS="+"
echo ${ECM_PORT[*]}
IFS=$IFS_SAVE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2009 11:18 PM
тАО04-16-2009 11:18 PM
Re: print field seperators
thanks both and I'll be using the first solution as this is probably the most effecient and understandable but wanted to play around !
Chris.