mardi 9 juin 2020

Using an append pattern sed on AIX

I've been struggling trying to find a pattern with sed and then append a character on AIX. I have absolutely no problem on Linux, but I really don't get how it is supposed to work on AIX.

Very simple : I have a /tmp/test.txt :

1
2
3
4
5

And I want :

1
2
10
3
4
5

So that I can understand how it works on AIX.

On Linux, I can do

sed -i '/2/ a 10\' /tmp/test.txt

It works. On AIX, I know we have to do a work around because there's no -i. But even after looking at other topics like Find pattern and append in sed

I tried that, following their example

cat /tmp/test.txt | sed '/2/i\10' > /tmp/test.temp
cat /tmp/test.txt | '\|"2"|i\10' > /tmp/test.temp 

And probably dozen of other combinaisons, but I get something like it can't be parsed, or it's not reconized as a function. Or it can be run, but when I look at test.temp, nothing happened.

Thanks in advance,

Aucun commentaire:

Enregistrer un commentaire