June 27, 2007

How can you put the output of the following command into the variables provided?

DATE for the output of "date" command

  1. USERS for the output of "who | wc -l"
  2. UP for the output of "date; uptime"
  3. (Red Hat Linux)
  4. Assuming you are talking about shell scripting or shell commands in Red Hat Linux:

    DATE=`date`;
    USERS=`who | wc -l`;
    UP=`date; uptime`;

    Note the ` used above is not the single quote, but the backtick (the key to the left of the "1" on standard keyboards).

    To confirm that it worked, you can use:

    echo $DATE;
    echo $USERS;
    echo $UP;

Tags: ,

Tell a Friend Today!

del.icio.us Digg Furl Reddit Ask BlinkList blogmarks Blogg-Buzz Google Ma.gnolia Netscape ppnow Rojo Shadows Simpy Socializer Spurl StumbleUpon Tailrank Technorati Windows Live Wists Yahoo! Help

Permalink • Print

Track this entry

RSS BlogPulse

RSS Technorati Cosmos

Related Searches

, , , ,