- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- join output of two commands on one line
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
Forums
Discussions
Discussions
Discussions
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
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
08-12-2005 02:49 AM
08-12-2005 02:49 AM
I need to join the output of two commands onto a single line and ensure a "," (comma) exists between each field. What is the best way to do this?
e.g. these are the commands I want to output on a single line:
ls -l | awk '{print $1","$3","$4","$5","$9","}'
sum -r
so my output should be something like:
-rw-rw-rw-,root,sys,65432,filenamea,32508
-rw-rw-rw-,root,sys,65432,filenameb,3233
-rw-rw-rw-,root,sys,65432,filenamec,325221
-rw-rw-rw-,root,sys,65432,filenamed,1292
-rw-rw-rw-,root,sys,65432,filenamee,2838
.............
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2005 02:51 AM
08-12-2005 02:51 AM
Re: join output of two commands on one line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2005 03:09 AM
08-12-2005 03:09 AM
Re: join output of two commands on one line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2005 03:09 AM
08-12-2005 03:09 AM
Solutionfor i in $(ls -l | awk '{print $1","$3","$4","$5","$9","}' | grep -v ^total)
do
j=$(sum -r $(echo $i | cut -d, -f5) | cut -d" " -f1)
echo $i$j
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2005 03:25 AM
08-12-2005 03:25 AM
Re: join output of two commands on one line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2005 03:30 AM
08-12-2005 03:30 AM
Re: join output of two commands on one line
Here is my offering anyway:
for file in `ls`
do
sum=`sum -r $file | awk '{print $1 }'`
list=`ls -l $file |awk '{print $1","$3","$4","$5","$9","}'`
echo $list $sum
done