awk extract a string from a file

Hi,

I have a file which has thousand of lines with lines starting with

And I want to extract and show to user only the below string from all the lines

Please note note that the above string is a time stamp and it would be different on all the lines.

Please tell me how to extract and show only these string from a file.

Thanks in advance

If all that you are interested in is the time stamp , a simple

cat <file>|cut -c1-25

will do the job...

Something like this?

 
sed 's/\(\[.*\]\) .*/\1/'  input_file
awk -F"]" '{print $1"]"}' <myfile.txt

or

awk '{print $1,$2}' <myfile.txt

awk '{print $NR, $(NR+1)}'

What does that do exactly?
And how's it related to the OP?

thanks to your question, I found a mistake. to use awk built-in variables it should be

awk '{print $(NF-6) " " $(NF-5)}'

For example

# cat list.txt
[2010-03-03 16:28:44.035] DEBUG 2010-03-03 16:28:44,035 DEBUG :[ACTIVE]
[2010-03-04 16:28:44.035] DEBUG 2010-03-03 16:28:44,035 DEBUG :[ACTIVE]
[2010-03-05 16:28:44.035] DEBUG 2010-03-03 16:28:44,035 DEBUG :[ACTIVE]
# awk '{print $(NF-6) " " $(NF-5)}' < list.txt
[2010-03-03 16:28:44.035]
[2010-03-04 16:28:44.035]
[2010-03-05 16:28:44.035]

NR works only if in input fail i only one row
thnx
Kaido

Thanks a lot guys.

Below solution provided by joeyg solves my purpose

Thanks a lot to all who have replied. I will check all of them and reply.

Thanks.

sed -r 's/(\[.*\])(.*)\]$/\1/' file