Issue
I have files that look like this:
username
Total 0
username
Total 0
username
Total 0
username
Total 0
username
Total 0
But some are malformed and have the incorrect first line like this:
Total 0
username
Total 0
username
Total 0
username
Total 0
username
Total 0
I need a one liner that will delete the first line if it does not contain username
i tried it with sed but it does not work:
sed -e '1!b' -e '/username/!d'
Solution
perl -ne 'print if 1 != $. || /username/'
Answered By - choroba Answer Checked By - Robin (WPSolving Admin)