- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Dates in awk Scripts
Operating System - HP-UX
1820882
Members
3415
Online
109628
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2004 08:15 AM
тАО08-18-2004 08:15 AM
I'm trying to create a Header Record with a Date Stamp, and I can't figure out the syntax:
The following doesn't work:
BEGIN {
header_type = "H"
header_desc = "Display Name of File"
header_date = strftime("%y%m$d",systime())
header_filler = "||||"
print header_type "|" header_desc "|" header_date "|" header_filler
}
{
}
END {
}
Suggestions welcomed!
The following doesn't work:
BEGIN {
header_type = "H"
header_desc = "Display Name of File"
header_date = strftime("%y%m$d",systime())
header_filler = "||||"
print header_type "|" header_desc "|" header_date "|" header_filler
}
{
}
END {
}
Suggestions welcomed!
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2004 08:42 AM
тАО08-18-2004 08:42 AM
Solution
Hi,
I couldn't get it to work on HP-UX 11.11. My awk complains about the strftime function. I tried it on a Linux box and it seems to know about that function, and it seemed to work when I changed this line:
header_date = strftime("%y%m$d",systime())
to this:
header_date = strftime("%y%m%d",systime())
It seems happier with the '%d' instead of the '$d', and gives back something like this:
H|Display Name of File|040818|||||
Is that what you had in mind?
JP
I couldn't get it to work on HP-UX 11.11. My awk complains about the strftime function. I tried it on a Linux box and it seems to know about that function, and it seemed to work when I changed this line:
header_date = strftime("%y%m$d",systime())
to this:
header_date = strftime("%y%m%d",systime())
It seems happier with the '%d' instead of the '$d', and gives back something like this:
H|Display Name of File|040818|||||
Is that what you had in mind?
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2004 08:52 AM
тАО08-18-2004 08:52 AM
Re: Dates in awk Scripts
well strftime is a library function and isn't an awk command, so that isn't going to work.
what will probably work for is the getline command used as: command | getline variable
as your command use date. see the man page for more information
of course you could also pass the date as a variable, -v date=$(date) '{...
or as part of the environment ENVIRON["date"]
what will probably work for is the getline command used as: command | getline variable
as your command use date. see the man page for more information
of course you could also pass the date as a variable, -v date=$(date) '{...
or as part of the environment ENVIRON["date"]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2004 08:57 AM
тАО08-18-2004 08:57 AM
Re: Dates in awk Scripts
Yes, that's exactly what I needed... when I tried that here on my OS... I received the following error message:
nawk: calling undefined function strftime
source line number 10
So, there's something odd about my ability to recognize functions.
I'm currently using the following code:
"date +'%Y%m%d'"| getline header_date
I really appreciate your input and suggestion!
nawk: calling undefined function strftime
source line number 10
So, there's something odd about my ability to recognize functions.
I'm currently using the following code:
"date +'%Y%m%d'"| getline header_date
I really appreciate your input and suggestion!
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP