- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: shell script
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
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
тАО07-13-2006 06:20 PM
тАО07-13-2006 06:20 PM
shell script
I need to compile a mailing list from multiple line to one single line
From multiple line
abc@mydomain.com
bcd@mydomain.com
efe@mydomain.com
to single line
abc@mydomain.com,bcd@mydomain.com,efe@mydomain.com
Of course I can write the output to a file and do a while loop. Is there anyway I can do it in one single line of command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-13-2006 06:43 PM
тАО07-13-2006 06:43 PM
Re: shell script
- Tags:
- tr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-13-2006 06:45 PM
тАО07-13-2006 06:45 PM
Re: shell script
awk '{printf "%s,",$0}' file_name > out_file
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-13-2006 06:50 PM
тАО07-13-2006 06:50 PM
Re: shell script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-13-2006 08:28 PM
тАО07-13-2006 08:28 PM
Re: shell script
how about:
paste -s -d"," filename | sed "$ s/,$//"
- Tags:
- paste
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-13-2006 09:04 PM
тАО07-13-2006 09:04 PM
Re: shell script
so you need something more awk:
awk 'last {printf last","};{last=$0};END {print last}' filename
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-13-2006 09:23 PM
тАО07-13-2006 09:23 PM
Re: shell script
These two will not add a trailing comma
# perl -nle'push@x,$_}END{chomp@x;print join","@x' file
# perl -le'BEGIN{$/=undef}chomp(@x=<>);print join",",@x' file
The good tr example and this short command will
# perl -pe's/\n/,/' file
Enjoy, Have FUN! H.Merijn
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-13-2006 10:45 PM
тАО07-13-2006 10:45 PM