In a file , how to retrieve the lines which are the
multiples of 50 ? like 50,100,150th lines etc.

Answer Posted / shivu

root@chandru-VirtualBox:~# egrep "^[0-9]*[0|5]0" file
50
100
150
200
250
300
350
400
450
500
501
502
503
504
505
506
507
508
509
550
600
650
700
750
800
850
900
950
1000

But the below one is
root@chandru-VirtualBox:~# egrep "^[0-9][0|5][0]" file
100
150
200
250
300
350
400
450
500
550
600
650
700
750
800
850
900
950
1000

This is also not correct. up to some extend it is ok.

Is This Answer Correct ?    1 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the default permissions of a file when it is created?

498


How does path variable work?

547


Set up a Sev 2 alert when the Primary WA service fails. A windows batch script needs to be created that will monitor the WA service on the Primary and when the service stops/fails a Sev 2 TT is generated for a particular team ?

1716


How to print all array elements and their respective indexes?

510


What are the different types of commonly used shells on a typical linux system?

552






What is path in shell script?

638


Is cmd a shell?

598


What are the different variables present in linux shell?

612


How can I send a mail with a compressed file as an attachment?

556


How many fields are present in a crontab file and what does each field specify?

585


What can scripts do?

666


How do I debug a shell script?

567


What does echo $0 do?

586


what is info area how many types?

2291


How to use arguments in a script?

581