1

I've a text file with thousand of lines in it (each line has an email address) and I'd like to convert those to a CSV file using bash. The problem is I'm not well versed with Bash, so not sure how to go about doing it.

Any suggestions?

EDIT: File example:

[email protected]
[email protected]
[email protected]
[email protected]
4
  • 1
    sample input and desired output Commented Sep 11, 2015 at 12:49
  • 1
    a file where every line is just an email address is already a CSV. is there additional information in each line? Commented Sep 11, 2015 at 12:57
  • @SeanBright are you sure? I've tried to use the file to import into Drupal and got an error Commented Sep 11, 2015 at 12:59
  • 1
    would you care to share that error with the rest of us? Commented Sep 11, 2015 at 12:59

1 Answer 1

1

This is ugly but it should work:

while read email; do echo '"'${email//\"/\"\"}'"'; done < inputfile.txt > output.csv

This escapes " with "" which is how CSVs are escaped in Excel land.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.