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
Explain how you Automate your application using Shell scripting.
How to find duplicate record in file using shell script?
What is the first line in a shell script?
Can shell script run on windows?
How do I open the shell prompt?
Explain about the exit command?
What are the 3 standard streams in linux?
c program to display the information of given file similar to givan by the unix or linux command ls -l
What are the zombie processes?
What does it mean by #!/Bin/sh or #!/Bin/bash at the beginning of every script?
Where are cowrie shells found?
How do I run a .sh file on mac?
What does chmod do?
What is the use of .sh file?
In my bash shell I want my prompt to be of format '$"present working directory":"hostname"> and load a file containing a list of user-defined functions as soon as I log in, how will you automate this?