#TIL #linux #sed 첫번째 라인만 교체
2019-03-27$ cat test.csv header1,header2,header3 1,2,3 2,3,1 3,1,2 $ sed -i.bak -e "1s/[^,]/x/g” test.csv $ cat test.csv xxxxxxx,xxxxxxx,xxxxxxx 1,2,3 2,3,1 3,1,2
s
명령어 앞에 범위가 없으면 전체를 바꾼다. 1s
명령어로 첫 번째 라인만 바꾸게 했다. 1,3s
명령어는 첫 번째 라인부터 3번째 라인까지 변경한다.
sed 만세. 뭔가 교체하는 거면 sed를 가장 먼저 찾아보자.
참고 - Replace the first line in a text file by a string - stackoverflow
- category:
- til 174
@ohyecloudy
, ohyecloudy@gmail.com