티스토리 뷰

반응형
.
├── app.js
└── input.txt
  • 요런 구조일 때,
const fs = require('fs');
const { exec } = require('child_process');

// 요 부분은 본인이 원하는대로 후처리한다.
// 후처리가 필요없으면 fs.readFileSync만 해도 무방하다.
const text = fs.readFileSync('./input.txt', 'utf-8')
  .trim()
  .split('\n')
  .map(line => line.replace('\t', '='))
  .join(';');


exec(`echo "${text}" | pbcopy`, ((error, stdout, stderr) => {
  console.log(stdout);
}));
  • 요런 식으로 pbcopy를 활용할 수 있다.
    • node app.js로 실행하면 복사되어 있을 것임!
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함