1,$ line range; apply the following command on all lines ('$' in this context means last line). This part can be omitted since the full range is default. s/foo/bar/g substitute (s) 'foo' with 'bar', globally (g), which means all instances of 'foo' will be replaced with 'bar'. Any delimiter can be used (useful if your expression contains slashes), e.g. s!foo!bar!g <$1 feed input to sed from first positional argument ($1) > file.txt and write it to file.txt