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: 
You can combine `head` and `tail` to achieve this.

If the *nth* line from the bottom needs to be deleted

1. `head` reads from standard input and reports to standard output *total -n* lines from the top
2. `tail` reads and reports to standard output the bottom *n-1* lines from standard input.
3. Taken as a whole, the lines are thus reported to standard output in order, with the \*nth` line from the end being skipped

This solution depends on `head` leaving the file offset of the open file description just after the last reported line - I believe GNU `head` does indeed do this when standard input is redirected from a file

```
n=200; tmpfile=$(mktemp) && { head -n -$n; tail -n -$((n-1)); }<file >"$tmpfile" \
    && mv -- "$tmpfile" file

```
`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

```