Need help in writing a script that do internal grep on a log file..and extract acct no's from it..

I need to write a script, which takes the input a log file and create output file with acct no's line by line from selected records with text like (in red) :
18:51:18 | 217863|Acct 0110855565|RC 17608| 16 Subs| 1596 UsgRecs| 2 Secs| 430 CPUms| prmis2:26213 <MoveUsage d
aemon needs to run on this account before it can be billed.>
23:03:30 | 896529|Acct 2063947620|RC 17608| 8 Subs| 148 UsgRecs| 1 Secs| 280 CPUms| prbru6: 244 <MoveUsage d
aemon needs to run on this account before it can be billed.>

The output file should only contain acct no's ( in bold ) line by line..
:wall:
Can any one help me out in this..:confused:

Welcome to the forum.
Assuming the file format is fixed :

$ awk -F '[| ]' '{print $6}' file
0110855565
2063947620
$ 

Please use code tags next time.

grep Acct <inputlogfile-name>| awk '{print $4}' | cut -f 1 -d "|" >> <outputfile-name>

You can try below

tput bold
awk -F "|" '{print $3}' file

Output:

Acct 0110855565
Acct 2063947620

Regards,
Haris

Hi Anchal,
I need to send grep output of a log file as input to awk command..
I need to grep the log file like:
grep 'MoveUsage daemon needs to run on this account before it can be billed' <input Log File>
and this output of grep(which would be like):

18:51:18 | 217863|Acct 0110855565|RC 17608| 16 Subs| 1596 UsgRecs| 2 Secs| 430 CPUms| prmis2:26213 <MoveUsage d
aemon needs to run on this account before it can be billed.>
23:03:30 | 896529|Acct 2063947620|RC 17608| 8 Subs| 148 UsgRecs| 1 Secs| 280 CPUms| prbru6: 244 <MoveUsage d
aemon needs to run on this account before it can be billed.>

and from this output I need to extract only acct no's as I mentioned earlier..

grep 'MoveUsage daemon needs to run on this account before it can be billed' <input Log File> | awk -F '[| ]' '$6 ~ /[0-9]{10}/ {print $6}'

Hi anchal,
I ran the above suggested one,but it throwed error:

awk: syntax error near line 1
awk: bailing out near line 1

Which OS?

Use nawk or /usr/xpg4/bin/awk instead.