r/sed • u/someoddnonhuman • Aug 21 '22
replace something only on the first line
i am creating a script to check a script with shellcheck which apply's, i am wondering how to replace
/bin/sh
with
/usr/bin/env sh
only on the first line
5
Upvotes
1
u/[deleted] Sep 08 '22
try this:
sed -E '1 s_/bin/sh_/usr/bin/env sh_' or sed -E '1 s_(/bin)(sh)/usr\1/env/bash \2'