There is a para break at the end of my .csv file. I tried to remove the blank line that is at the end of the file using the following command.
sed -i '/^$/d' combined.csv
But it does not work and a blank line is still there. I can remove the last line using the following command.
sed -i '$d' combined.csv
But is it possible to check if the last line is really empty before removing it?
Update:
I am using the following command to check if each line start with a number.
sed -i '1s/^[^0-9]*//' combined.csv
This checks only for the first line and not the rest of the lines. How do I make it check all the lines in the file? This might solve my problem.
There is also a very handy keyboard shortcut to delete rows (columns or cells). Press Ctrl + – on the keyboard. That's it! Our blank rows are gone now.
To start removing empty lines, open your document with Microsoft Word. Click “Home” in the menu and then select “Replace” on the right of the screen. Then click “Replace All” at the bottom of the window. After you click, all the blank lines will be removed from your document.
Try ${/^$/d;}
this will only match an empty line if it is the last line of the file.
Update: for your second question, just remove the 1 before the s, i.e.: sed -i 's/^[^0-9]*//' combined.csv
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With