Question: There are unknown number of lines in a file. How to delete nth line (when counted from the bottom) with one-liner command (you may use more than one if it is necessary) on Unix platform.

Answer: 
if `$n` hold number of line to delete

to delete a single line use

```
printf "\$-%d+1,\$-%d+1d\nwq\n" $n $n| ed -s file

```

to delete n last lines

```
printf "\$-%d,\$d\nwq\n" $n | ed -s file

```

where

* `\$%d,\$d` tell ed to delete n last lines (printf will insert n)
* `wq` write and quit
* `-s` in `ed -s` will keep ed silent.
* note that no provision is made to check you have enough line to delete.

sadly range **from end** can't be specified in `sed` ...
`sed` cannot calculate nth row from bottom by itself, so we need to that before, e.g. using `awk`:

Delete 4th row from bottom:

```
delrow=$(awk -v n=4 'END { print NR-n+1 }' file)
sed -i "${delrow}d" file

```