The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
NIM Questions tb0ne AIX 5 08-16-2007 08:23 AM
Few questions gina Shell Programming and Scripting 2 05-28-2007 06:47 AM
A few questions... halluc1nati0n UNIX for Dummies Questions & Answers 2 03-28-2007 11:29 AM
3 questions in 1 alikun UNIX for Dummies Questions & Answers 2 03-27-2007 03:59 AM
ftp questions lewisoco UNIX for Advanced & Expert Users 5 10-27-2005 06:45 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 06-28-2006
bobo bobo is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 148
Unhappy awk questions

I have the following script:

set DAY=`date +%y%m%d`
set H=`date +%H`
set M=`date +%M`

awk 'NR==1 {printf "MY HEADER WITH TIME STAMP $H \n"} {print $0}' data1> data2

my result is:

MY HEADER WITH TIME STAMP $H
......data information....
......data information....


How can I get is have the time stamp there but not the $H. The $H should the time to be display.

for example: at 10 o'clock I should have:

MY HEADER WITH TIME STAMP 10

Thanks!
  #2 (permalink)  
Old 06-28-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
You can try something like this:

Code:
#!/bin/ksh

DAY=`date +%y%m%d`
H=`date +%H`
M=`date +%M`

nawk 'NR==1 {printf "MY HEADER WITH TIME STAMP '$H' \n"} {print $0}' data1 > data2

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 05:07 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