in a file

问题描述 投票:0回答:1

I need help in replacing the first string and only first string in n lines in a file.

The format is as follows:

Str1|str2|str3|str4|str5||

This is the format of the file and i need to replace only str1 in all the lines and keep the rest as it is.

I tried

sed -i “s#.*|||||#Test|||||#g” filename.txt

This replaces the first text with ‘Test‘ which Is fine but replaces the rest of the texts with

linux unix sed replace
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.