Post History
Inasmuch as ed is the standard editor, you could do: ed -s "$file" <<EOD 1c $env . w EOD or: printf '%s\n' 1c "$env" . w | ed -s "$file" If the first line might not be a shebang,...
#3: Post edited
- Inasmuch as `ed` is the standard editor, you could do:
- ```
- ed -s "$file" <<EOD
- 1c
- $env
- .
- w
- EOD
- ```
- or:
- ```
- printf '%s\n' 1c "$env" . w | ed -s "$file"
```
- Inasmuch as `ed` is the standard editor, you could do:
- ```
- ed -s "$file" <<EOD
- 1c
- $env
- .
- w
- EOD
- ```
- or:
- ```
- printf '%s\n' 1c "$env" . w | ed -s "$file"
- ```
- If the first line might not be a shebang, using the `i` command instead of `c` could be safer.
#2: Post edited
- Inasmuch as `ed` is the standard editor, you could do:
- ```
- ed -s "$file" <<EOD
- 1c
- $env
- .
- w
- EOD
- ```
- or:
- ```
printf '1c\n%s\n.\nw\n' "$env" | ed -s "$file"- ```
- Inasmuch as `ed` is the standard editor, you could do:
- ```
- ed -s "$file" <<EOD
- 1c
- $env
- .
- w
- EOD
- ```
- or:
- ```
- printf '%s\n' 1c "$env" . w | ed -s "$file"
- ```
