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

Answer Posted / shivu

i=50
lines=`wc -l file | cut -d" " -f1`
while [ "$i" -le "$lines" ]
do
head -n $i file | tail -1
i=`expr $i + 50`
done


It works for anything.. :)

Is This Answer Correct ?    3 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

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

556


Using set -A write a script to print the output of the ls command in 5 columns with two spaces between each column. Pretend that ls does not have multicolumn output.

2031


Is shell scripting a programming language?

576


What is the first line in every perl script called?

554


How to print all the arguments provided to the script?

557






How important is shell scripting?

543


What is shift command in shell script?

523


write a shell script to generate a alert ? like when ur birthday came then generate a alert ur birthday is today like that ?

3591


How do I open a jshell in cmd?

598


What is shell terminal?

547


Can shell script run on windows?

566


Is powershell a bash?

590


What is shell company all about?

575


What is the significance of the shebang line in shell scripting?

531


What is console line?

571