-1

Can someone tell me a 'one line' sed command that prints out the lines 100-104 and 205-210 of of any file that has 500 lines in total ?

I tried this one :

sed -n '100,104'p unique_undetermined
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
Keshav
  • 39
  • 5
  • 1
    you can issue multiple commands separated by `;` – Sundeep Apr 06 '20 at 03:48
  • 1
    The requirement to only process files with 500 lines or more complicates your problem (as does your "need" to have a one-liner (these are highly overrated!)) . . You could surround your improved `sed` cmd per Sundeep's comment with `if (( $(wc -l < fileName) > 500 )) ; then `sed ... ; else echo file not big enough to process ; fi` . Good luck. – shellter Apr 06 '20 at 04:51
  • Does this answer your question? [How can I extract a predetermined range of lines from a text file on Unix?](https://stackoverflow.com/questions/83329/how-can-i-extract-a-predetermined-range-of-lines-from-a-text-file-on-unix) – Wiktor Stribiżew Apr 06 '20 at 08:18

1 Answers1

-1

@Sundeep is suggesting the following:

sed -n '100,104p;205,210p' unique_undetermined
rtx13
  • 2,580
  • 1
  • 6
  • 22