Formatting using awk

Let's say I write a simple script that contains the following:

date | awk '{print $1}'
date | awk '{print $2}'

Of course, when I run the script the output will look similar to:

Tue
Mar

What if I want my ouput to be on one line as follows:

Tue Mar

What changes would I need to make to my script (#!/bin/csh)?

THanks

-cd

date | awk '{print $1" "$2}'

will do what you asked for - of course, there are lots of different ways to do this (especially if you still want to keep two separate date commands)

#!/bin/csh
set d1=`date | awk '{print $1}'`
set d2=`date | awk '{print $2}'`
echo "$d1 $d2"
exit

Of course, you are then using up computing power doing a command twice...

#!/bin/csh
date +"%a %h"
exit

You can just use field descriptors with the date command to achieve the same result:

date +"%a %b"