AWK alias with parameters

Hello,

How can I make an alias of an AWK one liner that prints specific lines from a file like below?

# from a command like this:
awk 'NR == 100, NR == 150' file.cfg

The alias I want to make should work like this(I guess):
 <alias_command> <file.cfg><start_line><end_line>

So the line numbers can be attached at the end of the file name like file.cfg_100_150 and the AWK should parse the file name first in order to get the lines(if that's possible).

Thanks.

Basically it's like this:

root@isau02:/data/tmp/testfeld> cat infile
eins
zwei
drei
root@isau02:/data/tmp/testfeld> alias yo="awk 'NR == 2 {print}' \$1 > newfile"
root@isau02:/data/tmp/testfeld> yo ./infile
root@isau02:/data/tmp/testfeld> cat newfile
zwei

For the output file having the line numbers in it's name, I have no good short idea atm. Maybe someone else comes up with it or you try a bit too :slight_smile: