Skip to content

Instantly share code, notes, and snippets.

@viktorkelemen
Created December 13, 2011 04:04
Show Gist options
  • Save viktorkelemen/1470513 to your computer and use it in GitHub Desktop.
Save viktorkelemen/1470513 to your computer and use it in GitHub Desktop.
Replace line break with comma
# Inline
echo 'id1\nid2\nid3' | tr -s '\n\r' ','
# From file
cat ids_width_linebreaks.txt | tr -s '\n\r' ','
# From/to a file
tr -s '\n\r' ',' < ids_with_linebreaks.txt > ids_with_commas.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment