Skip to main content
Question

Why is this script pulling line endings?

  • May 14, 2020
  • 2 replies
  • 23 views

chrisdaggett
Forum|alt.badge.img+7

Looking for advice on why this command would pull line endings from csv, any help appreciated.

awk -v var="INSERTSERIALHERE" -F',' '$0 ~ var {print $2}' /tmp/googleemail.csv

2 replies

Forum|alt.badge.img+9
  • Contributor
  • May 15, 2020

Hi @chrisdaggett ,
Not 100% sure what you mean by line-ending, but if you are looking for the script to output a different column, you can adjust the print value:

#Pulls second value
{print $2}

To:

#Pulls first value
{print $1}

Also your field separator is set to a comma:

-F','

Which is standard for Comma Separate Values, but if there is unconditional formatting you may have to change it.

Feel free to add an example csv if you are still running into errors


chrisdaggett
Forum|alt.badge.img+7
  • Author
  • Valued Contributor
  • May 15, 2020

Well I was wrong, I thought it was pulling n/ because of the line endings, but I think it was because a few of the serial #'s were set to n/a (students who did not have a laptop). What I don't understand is why it started pulling the next line?

It is a 2 column CSV, pulling second value.

Example shared below, I have cleaned up the sheet it was pulling from originally to remove the "N/A" but still nervous to push this out again lol.

Example CSV