Grepping only dates from a log file

awk gave me error but nawk gave me result

10.3.45.243 07/13/2013
xnetang5 05/23/2014
erver0124 05/27/2014
server0186 05/23/2014
server1356 05/23/2014
server2154 05/23/2014
server0168 05/23/2014
tstarg01 05/23/2014
tstarg01 05/23/2014
tstarg01 05/23/2014

Thank you so much Akshay !!.. you save many lines of my script...

I told you to use nawk if you are using sunos/solaris in post #12 , you must have forgotten :), anyways glad to know that you finally got what you expected.

Hey Akshay,
Tried using nawk as well

bash-3.00$ nawk --re-interval 'match($0,/([[:digit:]]{2}\/){2}[[:digit:]]{4}/,m){print $1, m[0]}' dump1.log
nawk: unknown option --re-interval ignored
nawk: syntax error at source line 1
context is
>>> match($0,/([[:digit:]]{2}\/){2}[[:digit:]]{4}/, <<<
nawk: bailing out at source line 1

Even for the last command i got error for awk, wut when i ran it as nawk it worked. for every command you gave i tried it using both awk & nawk.
How ever, it worked for me.. thank a lot for your time.... !!!

---------- Post updated at 07:03 AM ---------- Previous update was at 07:00 AM ----------

hope i am not harassing you with my silly doubts...

I have another basic doubt.

I want to run a script file as root, but inside that i need a command that needs to run as different user, is that possible.

can we use

sudo -t <user> <script file>
pbrun -u <user>  <script file> 

thanks again..!!

Please use below one, --re-interval option is avaiable in gawk

$ nawk -F';' 'match($0,/[0-9]+\/[0-9]+\/[0-9]+/){print $1,substr($0,RSTART,RLENGTH)}' file
su -c <script>

ok, say script.sh has the below lines, and i need to run the script as root or user. please tell me if this will work

#!/bin/bash

sudo -t wam /usr/local/wam/stopwam -r     ------- this needs run as wam user
/usr/local/web/stopweb -a                             --- this needs to run as root
/sbin/init 6                                                   --- need to run as root. 

this is my requirement, and i need to schedule this job, and i need to give user (either root or wam) while scheduling it.

As someone already tagged this thread as solved, and you seem to be heading off in a tangent, I'd ask you, please, to start a new thread. Thanks.

And, despite all your fancy ways of trying to delineate your code, you would still be quicker using the code tags button, or typing

```text
...
```

!

The button looks like this: