papai has asked for the wisdom of the Perl Monks concerning the following question:
From a linux prompt I can issue a date command and pipe it to an awk in result getting a single number.
In result I get a value of "18", today's day of the month./bin/date | awk 'BEGIN {FS=" "}{print $3}'
I want to capture that single value in my script but it seems when I add a pipe to my command it doesn't work. Here is a snippet of the code:
When this code is run I get "Fri Jun 18 11:48:34 EDT 2010". How do I get the single value of 18? The above examples are hypothetical, I know there are lots of date modules/packages out there available, I am concern about using pipes in my system calls. Thanks. T$day = `/bin/date | awk 'BEGIN {FS=" "}{print $3}'`; print $day;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: system call (backticks) with pipes
by Corion (Patriarch) on Jun 18, 2010 at 16:50 UTC | |
|
Re: system call (backticks) with pipes
by ikegami (Patriarch) on Jun 18, 2010 at 17:22 UTC | |
|
Re: system call (backticks) with pipes
by ikegami (Patriarch) on Jun 18, 2010 at 17:24 UTC | |
by papai (Novice) on Jun 18, 2010 at 19:05 UTC | |
by Anonymous Monk on Nov 17, 2016 at 20:28 UTC | |
by Corion (Patriarch) on Nov 17, 2016 at 20:26 UTC | |
by AnomalousMonk (Archbishop) on Nov 17, 2016 at 21:06 UTC | |
by hippo (Archbishop) on Nov 17, 2016 at 22:32 UTC | |
|
Re: system call (backticks) with pipes
by Anonymous Monk on Jun 18, 2010 at 16:53 UTC | |
|
Re: system call (backticks) with pipes
by Anonymous Monk on Jun 18, 2010 at 17:31 UTC |