change line

Hello,

I want to change a line at file whit a script

i want to change line 150 for example, write hello and remove text of this line

EXAMPLE

LINE 150: my mother

change to:

LiNE 150: HELLO

sed '150s/.*/HELLO/' infile
1 Like

try:

sed "150s/.*/HELLO/" FICHERO_IN
1 Like

thanks, but....how i can save the file?

waht is .*���

tahnks

Hello,

I recommend you read: Sed - An Introduction and Tutorial

.* is:
. = any character

  • = the "anterior" repeated any times

so, .* is "any phrase".

Then sed change "any phrase" in the line 150 for "HELLO".
You can redirect to other file with >:

sed "150s/.*/HELLO/" FILE_IN > FILE_OUT
1 Like