Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

same line

Status
Not open for further replies.

vti

Technical User
Feb 26, 2001
189
TR

Hi all
ý am trying to put two print at same line like;

echo 'line1' >> out.txt
date >> out.txt

and when i edit out.txt it gives ,

"line1
"Wed Jan 23 13:41:48 EET 2002

But i want to put them together like ;

"line1 Wed Jan 23 13:41:48 EET 2002

but how?

thanks.
 
unixadmin,

you can do this with awk:

Code:
awk 'BEGIN { print "line1", strftime("%d %m %Y %H:%M:%S", systime()) }'

strftime's format is similar to that of printf.

Bye!

KP.
 
Thanks for answer,
I have tried but it didn't work or i couldn't run it.It gives this error.

# awk 'BEGIN { print "line1", strftime("%d %m %Y %H:%M:%S", systime()) }'
line1 awk: Function strftime is not defined.

The source line number is 1.

 
This should work OK ...

echo "line1\c" >> out.txt
date >> out.txt

The \c in the echo string supresses a carriage return at the end of the line.

Greg.
 
Hi:

Don't mean to insult anybody's intelligence, but the systime function call, is an an extension of GNU awk, gawk. Unfortunately, you won't find it on the old awk interpreters such as System V or BSD.

Regards,

Ed
Schaefer
 
Then Get Gawk. It's supported on SYSV/BSD.

Another way for the splitters.

awk ' {
a = "line1"
"date" | getline boogah
print a, boogah >> file
}'
 
Marsd:

I agree with getting gawk if you can. Unfortunately, in a world-wide corporate environment, you can't always get what you want.

Ed
 
Us backwoods folk don't know nuthin 'bout that.
We does what we wants when we wants it.
 
Thanks a lot .
It works well
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top