Dnaiel
Dnaiel

Reputation: 7832

saving excel file in a mac with newline recognizable by linux

I find myself doing this very often.

Open a csv file in a mac, save it as a csv on my mac, transfering the file via scp to linux, then scping the file back to linux, and then having to convert the file new lines to linux format once in linux.

Is there a way to avoid the 'converting new lines to linux format from mac step'? It's getting quite annoying to have to do this step every time i move files back and forth.

Upvotes: 0

Views: 340

Answers (1)

mouviciel
mouviciel

Reputation: 67879

You can define a bash function and use it in place of scp:

csvtransfer() {
  csvfile="$1"
  perl -i -ne 's/([^\r])\r/$1\n/g; s/\r//g; print;'  "$csvfile"
  scp <options> "$csvfile"
}

Upvotes: 1

Related Questions