Thursday, March 23, 2017

Bash: sed -part XI


read and delete command together


# cat detail.txt


Blum, R         Browncoat
McGuiness, A    Alliance
Bresnahan, C    Browncoat
Harken, C       Alliance




# cat notice.std

Would the following people:
LIST
please report to the ship's captain.






# sed '/LIST/{
> r detail.txt
> }' notice.std


Would the following people:
LIST
Blum, R         Browncoat
McGuiness, A    Alliance
Bresnahan, C    Browncoat
Harken, C       Alliance
please report to the ship's captain.

However, this still leaves the placeholder text(LIST) in the output.

------------------------------
To remove the placeholder text(LIST), just use the delete command(d):


# sed '/LIST/{
> r detail.txt
> d
> }' notice.std




Would the following people:
Blum, R         Browncoat
McGuiness, A    Alliance
Bresnahan, C    Browncoat
Harken, C       Alliance
please report to the ship's captain.

No comments:

Post a Comment