Extract only specific part from a file
Hello All,
I would like to know if there is a better way to achieve the below task: Task: Copy lines 10 to 50 from a files that contains 100 lines. My approach: 1st) use head command and then list first 50 lines and then tail last 40 lines. 2nd) Do a while loop with a counter and then when counter reaches to 10 start writing it to another file up to the point where the counter is 50 and then exit. I would like to know if there are any other simple and straight approach using which I can directly copy lines 10 to 50. Help and suggestions on this question are greatly appreciated. Thanks. |
Perhaps not. You can also use perl/python/ruby or any other script interpreter for doing it. Or you can make a generic 'C' executable for doing it so that it's useful for general purpose use.
|
Probably sed is simplest - see the manpage for address range usage.
|
Agreed, sed would be the simplest. awk, perl and others can also easily perform the task.
|
All times are GMT -5. The time now is 10:08 PM. |