awk questions


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers awk questions
# 1  
Old 06-28-2006
Data 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  
Old 06-28-2006
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

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

awk questions using sort and grep

1. The problem statement, all variables and given/known data: So i'll probably get told off for this but I have a few problems and rather than clog up the whole forum I'll post them here. Please bare in mind I am a complete novice when it comes to all this and so if you help please treat me like a... (4 Replies)
Discussion started by: jamesb18
4 Replies

2. Shell Programming and Scripting

Couple of easy questions for experts on awk/sed

Hello Experts.. I have 3-4 C codes with Oracle SQL statements embedded. All the SQL statements starts with EXEC SQL keyword and ends with ;. I want to extract all the SQL statements out of these codes. I did awk '/^EXEC SQL/,/\;/' inputFile (I use this on all of the codes individually). That... (2 Replies)
Discussion started by: juzz4fun
2 Replies

3. Shell Programming and Scripting

awk questions

Hi All, I have a file in the format shown below. I need to pick up only those lines which have the highest value in column 4 , based on column1. The lines marked as bold should be the output. Any help is appreciated! Input file : -10.5|6|L|32|MPP||R||012009|E... (12 Replies)
Discussion started by: nua7
12 Replies

4. AIX

Simple AWK cleanup/questions AIX

I have an unfortunate need to redo a bunch of disk settings on a VIOS on AIX, so I was putting together a quick script to scrub everything it has, make the changes, and then put the mappings back. It works, I just am trying to get my awk a bit more up-to-snuff and wanted to know the proper way to... (2 Replies)
Discussion started by: Vryali
2 Replies

5. Shell Programming and Scripting

Awk/Nawk Questions

Hi Guys, This is the Input: <xn:MeContext id="XXX012"> <xn:ManagedElement id="1"> <xn:attributes> <xn:userLabel>XXX012</xn:userLabel> <xn:swVersion>R58E68</xn:swVersion> </xn:attributes> </xn:ManagedElement> </xn:MeContext>... (4 Replies)
Discussion started by: smarones
4 Replies

6. Shell Programming and Scripting

basic awk questions

I find an script with awk sitting around. I went through some online manuals, but I can't figure out exactly how it works. I can't post the whole program. Not allowed. This is the line that is confusing me. I get when else is in the script grep -v "^REM " $1| grep -v "JUNK;" | awk -F" "... (2 Replies)
Discussion started by: guessingo
2 Replies

7. Homework & Coursework Questions

Print questions from a questions folder in a sequential order

1.) I am to write scripts that will be phasetest folder in the home directory. 2.) The folder should have a set-up,phase and display files I have written a small script which i used to check for the existing users and their password. What I need help with: I have a set of questions in a... (19 Replies)
Discussion started by: moraks007
19 Replies

8. Shell Programming and Scripting

Some questions about grep/awk

Hi guys. I need to filter some values from a number of log files. One of the files is: Interconnect Utilisation Results: Achieved Maximum Number of Concurrent Connections: 17 Statistics for Average Number of Concurrent Connections: Point Estimation: Confidence Interval: ... (2 Replies)
Discussion started by: Faaz0
2 Replies

9. Shell Programming and Scripting

...yet another string of awk/sed questions from a RegExp-Challenged luser %-\

Greetings all, ...here is yet another string of awk/sed questions from a RegExp-Challenged luser :eek: I'm looking to have sed/awk do some clean-up on routing tables and to that end, I would like to do the following: 1.) If a line contains the word "masks" or "subnets" prepend CR/LF to... (16 Replies)
Discussion started by: SteveB-in-LV
16 Replies

10. UNIX for Dummies Questions & Answers

Questions on AWK

Hi, Could someone tell me how to use a varible in the one of the sections of the awk command below which adjusts the spacing (i.e. "%-5s%-10s%-15s")? echo "1 2 3" | awk ' { printf("%-5s%-10s%-15s",$1,$2,$3); printf("\n"); } ' e.g. I have a variable named LENGTH which has the value 8 and I... (2 Replies)
Discussion started by: stevefox
2 Replies
Login or Register to Ask a Question