Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
awk を使用してファイル内のすべての行の最初の 100 文字を置き換えるにはどうすればよいですか? このファイルにはフィールド区切り文字はありません。すべてのフィールドは固定幅です。また、データにばらつきがあるため、検索と置換を使用できません。
どうsedですか?最初の 100 文字を say に置き換えるにはA:
sed
A
$ sed -r 's/.{100}/A/' file
結果に満足したら、次を使用してファイルを書き換えます-i。
-i
$ sed -ri 's/.{100}/A/' file
awk '{print "replacing text..." substr($0,100)}'