我正在编写一个bash脚本,用于修改一个如下所示的文件:
--- usr1 ---
data data data data
data data data data
data data data data
--- usr2 ---
data data data data
data data data data
--- usr3 ---
data data data data
--- endline ---
One question is: How to add next user line --- usrn ---
after last user data lines?
Second one is: How to delete specific user data lines (data lines and --- userx ---
) i.e. I would like to delete usr2 with all his data set.
It must work on bash 2.05 :) and I think it will use awk or sed, but I m not sure.
A little edit here: In fact usernames are not numbered. We don t know what users will come up with. We only know that the name will be inside ---
pattern