Question: Application for which I'm writing service file expects its `STDIN` to be connected to the `tty`, or in other words to be run on the terminal. `Systemd` has the following settings which do the trick for my application, however here I use statically configured `tty` path, which could potentially already be used by other application or simply do not exist on the system.

```
StandardInput=tty-force
TTYPath=/dev/tty30

```

It would be much nicer if `systemd` (or me for that matter) could figure out unused `pseudoterminal` pair and use that instead.

Answer: 
* With `awk`:

```
awk -v cnt=1004 '{ sub("^[^;]+", cnt++) } 1' file.csv

```
* With shell:

```
cnt=1004
while read -r line; do
    printf '%d;%s\n' $cnt "${line#*;}"
    let cnt++
done <file.csv

```
* With `jot`, `paste`, and a shell that can handle `<(...)` redirections:

```
paste -d\; <(jot $(wc -l <file.csv) 1004) <(cut -d\; -f2- file.csv)

```
* With Vim:

```
:let cnt=1004 | g/^/ s/^[^;]\+/\=cnt/ | let cnt+=1

```
* With Perl:

```
perl -F\; -lpe 'BEGIN{ $cnt=1004 } $F[0]=$cnt++; $_=join ";", @F' file.csv

```
Use Python, it's easy to read, understand, and maintain - and it's available on most Unix installations:

```
python - << "EOF" > outfilename
for index, line in enumerate(open("filename"), start=1004):
    linedata = line.strip().split(';')
    linedata[0] = str(index)
    print(';'.join(linedata))
EOF

```