sed Command

Hello,

I'm working with this command which I'm having trouble understanding it:

sed -e '1,$ s/SUB/N/g' < $1 > file.txt

Where SUB stand for an special character with code in ASCII is 0x1A, notepad read it as a right arrow.

Any help will be appreciated.

What do you mean "stands for a special character"? "SUB" is just "SUB", the three letters. Are you trying to substitute for 0x1a?

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

My guess is you are trying to do the following:

$ tr "\032" "N" < test
N

\032 (same as \0x1A) gets changed to N

Substitute character aka Control-Z (suspends in UNIX, EOF in DOS).

Regards,
Alister

1 Like

Thank you very much for your replays. mirni your post was very explanatory.