The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Append text at end of the first line in a file catgovind Shell Programming and Scripting 7 05-01-2008 07:33 AM
Building Full-Text Search Applications with Oracle Text iBot Oracle Updates (RSS) 0 04-06-2008 05:10 AM
how to append text into a file. beilstwh Shell Programming and Scripting 2 03-06-2007 05:51 PM
using sed to append text to the end of each line Redg UNIX for Dummies Questions & Answers 8 07-26-2006 10:59 AM
grep multiple text files in folder into 1 text file? coppertone UNIX for Dummies Questions & Answers 7 08-23-2002 02:50 PM

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 04-05-2005
801238429 801238429 is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 10
Text Append

I'm creating a script that counts the number of users currently online, then records that in a file called "log.txt" along with the time. Everytime the script is ran, the script appends the "log.txt"

this is what I have:

who|wc|cut -c6,7>>log.txt
date|cut -c12-24>>log.txt


After running the program, I checked the "log.txt" and this is what it had:

28
10:48:35 EDT


How will I make it so the "number of users" and "time" are beside each other in one line? (ex: 28 10:48:35 EDT)
  #2 (permalink)  
Old 04-05-2005
kduffin's Avatar
kduffin kduffin is offline Forum Advisor  
UN1X
  
 

Join Date: Nov 2003
Location: Maryland
Posts: 449
There's any number of ways that you can do this, though I must admit it sounds suspiciously like homework. So not to deviate to far from what you've already done:

WHO=`who | wc -l | sed -e"s/ * //g"`
NOW=`date|cut -c12-24`

echo "$WHO $NOW" >> log.txt

Cheers,

Keith
  #3 (permalink)  
Old 04-05-2005
801238429 801238429 is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 10
It's not homework. I'm trying to learn unix on my own. I'm just playing around with making scripts. Thanks for the help! I actually learned pretty much DOS and everything else that has to do with computers by what I am doing right now with unix.
  #4 (permalink)  
Old 04-05-2005
kduffin's Avatar
kduffin kduffin is offline Forum Advisor  
UN1X
  
 

Join Date: Nov 2003
Location: Maryland
Posts: 449
Great. Sorry for my assumption. Look forward to your future posts.

Keith
  #5 (permalink)  
Old 04-05-2005
Just Ice's Avatar
Just Ice Just Ice is offline Forum Advisor  
Lights on, brain off.
  
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 637
try this one ... (note the backticks in bold red) ...
Code:
echo "`who|awk 'END {print NR}'` `date|awk '{print $4, $5}'`" > log.txt
  #6 (permalink)  
Old 04-05-2005
801238429 801238429 is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 10
got it! Thanks people!
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 10:14 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