How do I replace a space in a text file?

Julipkq

New member
How do I replace a space in a text file?
Answer
A few choices:
  1. The classic, use tr : tr ‘ ‘ ‘n’ < example.
  2. Use cut cut -d ‘ ‘ –output-delimiter=$’n’ -f 1- example.
  3. Use sed sed ‘s/ /n/g’ example.
  4. Use perl perl -pe ‘s/ /n/g’ example.
  5. Use the shell foo=$(cat example); echo -e ${foo// /\n}
 

Tìm kiếm

Back
Top