The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Linux FAQ Items prashant_ohol Gentoo 11 09-12-2006 11:21 AM
Comma Seperated List of Values brap45 Shell Programming and Scripting 9 02-23-2006 05:12 AM
Handling .CSV( Comma seperated value) in awk Laud12345 Shell Programming and Scripting 1 05-09-2005 05:41 PM
How to load comma seperated values file (*.csv) into Oracle table handynas UNIX for Advanced & Expert Users 4 06-24-2002 01:35 PM
How to load comma seperated values file (*.csv) into Oracle table handynas UNIX for Dummies Questions & Answers 5 06-05-2002 12:10 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-03-2007
insania insania is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 30
change list to comma seperated items

I have a list of servers in a file called serverlist like this

server1
server2
server3


i need to have them (with no trailing comma, the program does not like that)

server1,server2,server3

so far i have been using

HOSTS=/tmp/serverlist
HOSTS=${HOSTS:-$(grep -Ev "^#|^$" $HOSTS_LOCAL)}
HOSTS=$(echo $HOSTS |tr -s '\n ' ',,')
HOSTS=${HOSTS%,}


to achieve this. It works but is there a quicker easier way say like in one line. (I need the grep -Ev "^#|^$" because we have a lot and need to comment them out sometimes).

Sean
  #2 (permalink)  
Old 10-03-2007
radoulov's Avatar
radoulov radoulov is online now Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,915
Yes


Code:
% cat file
server1
server2
server3
% paste -sd, file
server1,server2,server3

  #3 (permalink)  
Old 10-03-2007
insania insania is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 30
Thumbs up Perfect

The paste command worked great and did just what I was looking for. I appreciate the help.

Sean
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:04 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0