UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 13th, 2011, 06:21 AM
drapes33 drapes33 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Posts: 2 drapes33 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 12 sec
Reputation Power: 0
Constructing a file with date and time

Hi
I am a novice and have an existing script which creates a text file.
I need to enhance it so that it will now print a one-line report via “lp” as follows :

'On DD/MM/YYYY at HH:MM the following number of records were output : nn'

where nn is the number of records in my file.

I know I can get the value of nn via “wc –l”,
but do not know how to get the first part of the line with the date and time.

Presumably I should be creating a fileA,
and then ‘cat’ing fileA with a file with the contents
of the wc –l command,
but unfortunately do not know how to create fileA.

Any help would be most welcome !

Reply With Quote
  #2  
Old January 13th, 2011, 08:30 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 41 m
Reputation Power: 1485
You are ok with inserting the value of the number of records into the file, just repeat the same type of operation/function, but this time with suitable output from the date command:

Code:
runtime=$(date "+%x at %R")

Note that the %x pre-supposes your locale date format is d/m/y. If it isn't it is simple enough to construct the right format.
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc

Reply With Quote
  #3  
Old February 11th, 2011, 07:00 AM
drapes33 drapes33 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Posts: 2 drapes33 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 12 sec
Reputation Power: 0
many thanks Simon : working great.
sorry for the delay in response
illness & vacation

Reply With Quote
  #4  
Old February 11th, 2011, 07:50 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 41 m
Reputation Power: 1485
Three reasons to be cheerful:
you're feeling better
it worked
you had a good (hoepfully!) holiday

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Constructing a file with date and time

Developer Shed Advertisers and Affiliates



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap