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.
我可以使用 sed 重新插入数字吗?
我需要 sed 来读取输入,如果它以数字开头,请将其替换为方括号和数字
提前致谢
This should work with any sed:
sed 's/^[0-9]\{1,\}/[&]/' file
or
sed 's/^[0-9][0-9]*/[&]/' file