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` ...
An one-line, in-place solution:

With `gawk`, this will delete the 42nd line from the bottom:

```
gawk -i inplace 'i==0 {if(FNR>t){t=FNR}else{i=1}} i==1 && FNR!=t-42 {print}' input input

```

The 42 can be replaced with any number. If 0 is used then the last line is deleted.

Notice that the `input` file is specified twice. This forces two iterations of the file with gawk. In the first iteration (`i==0`) the total number of lines (`t`) is established. In the second iteration, the nth line from the end is not output.

The file is modified in place by using the `-i` option.