I have a CSV file formatted like this:
A @ B @ C @ D @ E
It should have five columns, unfortunately, some are missing the last column, e.g.:
A @ B @ C @ D
How can I add an extra @ to the end of every line which is missing the last column?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming that the spaces are part of the field contents and the delimiter is “@” alone (although other variations can easily be accommodated):
AWK creates missing intervening fields. Setting a field value to itself preserves existing contents if the field already exists or sets it and any intervening created fields to empty strings.