- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- AWK confusion
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
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
Community
Resources
Forums
Blogs
- 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
тАО03-29-2007 04:38 AM
тАО03-29-2007 04:38 AM
The script works well when I run it from the command line and pass the epoch time string.
# ./epoch_time.awk 1168097143
20070106152543
My problem is that this is not working when I am trying to use it from within a for loop or while loop. Such as:
# for i in $(cat myfile)
do
./epoch_time.awk ${i}
done
19700101000000
19700101000000
19700101000000
19700101000000
19700101000000
19700101000000
# head myfile
"1017942629"
"1018292324"
"1023462896"
"1023463449"
"1023469166"
It makes no difference to epoch_time.awk if the values have quotes around them or not.
This may be a case of not being able to see the forest for the trees. But I am confused and can't see where the problem may lie.
Any help is appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2007 04:41 AM
тАО03-29-2007 04:41 AM
Re: AWK confusion
epoch_time.awk hopefully attached this time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2007 04:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2007 04:49 AM
тАО03-29-2007 04:49 AM
Re: AWK confusion
of course is matters, whether your values in the file are quoted or not. Try
for i in $(
eval ./epoch_time.awk ${i}
done
as a shortcut to eliminate the quotes.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2007 04:53 AM
тАО03-29-2007 04:53 AM
Re: AWK confusion
fwiw... I don't care for any scripts with hardcoded day tables. Yuck.
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2007 05:00 AM
тАО03-29-2007 05:00 AM
Re: AWK confusion
I thought I tried stripping the quotes from the values in 'myfile'. Apparently not.
I guess what was throwing me off was that I had tried running the epoch_time.awk from the command line with the value quoted and it returned the correct value.
Live and learn.......
Thanks for pointing out what should've been fairly obvious.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2007 05:00 AM
тАО03-29-2007 05:00 AM
Re: AWK confusion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2007 05:01 AM
тАО03-29-2007 05:01 AM
Re: AWK confusion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2007 05:11 AM
тАО03-29-2007 05:11 AM
Re: AWK confusion
On the live and learn...
May I finish that sentence with 'perl'
:-) :-)
You'll be in Vegas right?
We'll have a beer and i'll get you going on Perl :-)
perl -ne 'chomp;s/"//g;@t=localtime($_); printf ("%4d%02d%02d%02d%02d%02d\n", $t[5]+1900, $t[4]+1, $t[3], $t[2], $t[1], $t[0])' myfile
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2007 05:59 AM
тАО03-29-2007 05:59 AM
Re: AWK confusion
A bit late I am, but even shorter with Perl:
# perl -MPOSIX -ne 'print strftime("%Y%m%d%H%M%S\n",localtime($_))' file
The nice part is that the directives to 'strftime' are as you find them in the manpages.
Regards!
...JRF...