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 does chmod do?

573


Explain about login shell?

633


Why do we write bin bash in shell scripts?

546


When should shell programming/scripting not be used?

590


What is sh in shell script?

573






What is scripting used for?

559


How do you find out What is your shell?

590


How to get the first line from a file using just the terminal?

596


How to pass an argument to a script?

592


What is path in shell script?

636


What are the different communication commands available in the shell?

515


Where are cowrie shells found?

574


What is the syntax of while loop in shell scripting?

569


How do you know which shell I am using?

587


What happens on a system call?

558