Sunday, January 28, 2024

[SOLVED] sed script interpretation: "0, /XXXX/! {0,/^XXXX/d}"

Issue

Trying to interpret what the following script does:

sed -i "0,/ACCOUNT/! {0,/^ACCOUNT/d}" file.txt

My interpretation is that it is trying to delete header rows (the ones that have ACCOUNT as a headername) if found. But running it on test files seems to be leaving the header rows intact.


Solution

The script deletes all lines from the line after the first line containing ACCOUNT up until and including a line starting with ACCOUNT.



Answered By - KamilCuk
Answer Checked By - Terry (WPSolving Volunteer)