Artificial intelligent assistant

Bash: How to append a range of lines from a file to another Let's say I have file contents similar to the following (fileA): lorem.ipsum=dolor sit amet. donec.non.nibh=ut tortor nam.mattis.lacus=et rhoncus sodales get.placerat=neque fringilla. What are the appropriate commands to get lines 2-3 to another file? I tried `cat`'ing file contents piped to `grep` with `-A` switch but this isn't exactly what I want as it depends on the pattern, not line number: cat fileA | grep -A1 "^donec" >> fileB fileB contents: donec.non.nibh=ut tortor nam.mattis.lacus=et rhoncus sodales

You can use sed to `p`rint a range selection (from 2 to 3):


~$ sed -n '2,3p' fileA
donec.non.nibh=ut tortor
nam.mattis.lacus=et rhoncus sodales


or use head to select the first 3 lines, and tail to select the last 2 lines (of the 3 lines):


~$ head -3 fileA | tail -2
donec.non.nibh=ut tortor
nam.mattis.lacus=et rhoncus sodales

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy a116d88d69003e992252837f577f330a