(a) Whenever the defendant has appeared in the action he may apply upon notice to the plaintiff to the court in which the action is pending or to the clerk of such court, for an order to discharge the attachment upon the execution of the undertaking mentioned in subsection (b) of this section; and if the application is allowed, all the proceeds of sales of property remaining in the hands of the marshal shall be released from the attachment and delivered to the defendant upon his serving a certified copy of the order on the marshal.
(b) Upon making the application the defendant shall deliver to the court to which the application is made an undertaking executed by one or more sureties, to the effect that the sureties will pay to the plaintiff the amount of the judgment that may be recovered against the defendant in the action. If the plaintiff demands it, the sureties shall be required to justify in the same manner as sureties for bail upon an arrest.
(c) The defendant may, at any time before judgment, except where the cause of attachment and the cause of action are the same, apply to the court in which the action is pending to discharge the attachment, in the manner and with the effect as provided in section 185 of this title for the discharge of a defendant from arrest.