Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8183307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:07:12+00:00 2026-06-07T01:07:12+00:00

I currently have a shell script with a section of code running remote shell

  • 0

I currently have a shell script with a section of code running remote shell commands like so:

grep -v "^[     ]*#" ${CONFIG_FILE} |
while read SERVER USER LOGDIR
do
{
echo "Stats for" $date
echo "${USER}"
echo "iTunes:"
time /bob/shared/ted/remote/rssh ${SERVER} "gzgrep -c \"iTunes Music\" ${LOGDIR}/*${date}*.gz | awk '-F:' '{total+=\$NF}END{print \"Total=\" total}'" 2>&1
echo
echo "Default"
time /bob/shared/ted/remote/rssh ${SERVER} "gzgrep -c \"Default Player\" ${LOGDIR}/*${date}*.gz | awk '-F:' '{total+=\$NF}END{print \"Total=\" total}'" 2>&1
echo
echo "The Rest"
time /bob/shared/ted/remote/rssh ${SERVER} "gzgrep -c \"Junk\"     ${LOGDIR}/*${date}*.gz | awk '-F:' '{total+=\$NF}END{print \"Total=\" total}'" 2>&1
} </dev/null 2>&1

done 2>${ERROR_FILE} >${STATS_FILE}

which gives me output like so:

Stats for 20120628
Rich
iTunes:
Total=0

real 0m2.09s
user 0m0.22s
sys  0m0.03s

Default:
Total=0

real 0m2.03s
user 0m0.23s
sys 0m0.00s

The Rest:
Total=0

real 0m2.03s
user 0m0.23s
sys 0m0.00s

Stats for 20120628
Ian
iTunes:
Total=2

real 0m21.44s
user 0m0.22s
sys 0m0.00s

Default:
Total=2

real 0m21.48s
user 0m0.21s
sys 0m0.02s

The Rest:
Total=0

real 0m2.03s
user 0m0.23s
sys 0m0.00s

etc etc…

What I want though is output like this in CSV format:

Rich,0,0,0
Ian,2,2,0

What’s the simplest way to modify the above code to get the output format I require?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:07:13+00:00Added an answer on June 7, 2026 at 1:07 am
    grep -v "^[     ]*#" ${CONFIG_FILE} |
    while read SERVER USER LOGDIR
    do
    {
    echo "${USER},"
    time /bob/shared/ted/remote/rssh ${SERVER} "gzgrep -c \"iTunes Music\" ${LOGDIR}/*${date}*.gz | awk '-F:' '{total+=\$NF}END{print total \",\"}'" 2>&1
    time /bob/shared/ted/remote/rssh ${SERVER} "gzgrep -c \"Default Player\" ${LOGDIR}/*${date}*.gz | awk '-F:' '{total+=\$NF}END{print total \",\"}'" 2>&1
    time /bob/shared/ted/remote/rssh ${SERVER} "gzgrep -c \"Junk\"     ${LOGDIR}/*${date}*.gz | awk '-F:' '{total+=\$NF}END{print total}'" 2>&1
    } </dev/null 2>&1 | tr -d '\n'
    
    done 2>${ERROR_FILE} >${STATS_FILE}
    

    I removed the extra echo’s, appended commas and made sure it’s on one line. Try it.

    If you don’t want the timing info either, just delete all the time invocations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have a perl script that runs forever on my server, checking a
I currently have a request to build a shell script to get some data
I currently have a shell script that process many images one after the other,
Currently have password protection on my main and sub directories, however I'd like to
I currently have a MySQL table like: id | friend 1 | 2 1
I have this shell script #!/bin/sh ############################################################# # Example startup script for the SecureTrading
I am currently trying to figure out why a shell script fails at concurrent
Currently i'm using a shell script to do the following: cd myproject1/ ant cd
I am currently running Cygwin on a target Windows Server 2003 machine to fire
I have a power-shell script with which I am trying to back up a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.