Skip to content
Advertisement

Merge sed commands into a script

I need to write these two sed commands in a single script.

sed -n '10,20p' file.txt | sed '1!G;h;$!d'

I selects lines in range from 10 to 20 and prints them in a reverse order Could anybody please help me with this?

Advertisement

Answer

This seems to be working

#!/bin/sed -Ef

10!G
h
20!d
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement