![Bash를 사용하여 파일 교체](https://linux55.com/image/194147/Bash%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20%ED%8C%8C%EC%9D%BC%20%EA%B5%90%EC%B2%B4.png)
나는 (다소 긴) 스크립트를 csh에서 bash로 번역하려고 합니다. "Makefile"이 필요하며 다음 명령을 실행합니다.
cpp_begin_line=`grep -n cpp_flags Makefile | sed 's/:/ /' `
cpp_end_line=`grep -n lioapi Makefile | sed 's/:/ /' `
여기의 값은cpp_start 라인예:
48 cpp_flags = \
71 CPP_FLAGS = $(cpp_flags)
그리고 가치cpp_end 라인예:
73 IOAPI = -L$(LIB)/ioapi/lib -lioapi
이 숫자는 Makefile의 48, 71, 73행에서 나옵니다. 그런 다음 스크립트는 작업을 수행하려고 시도합니다.
diff=1+$cpp_end-$cpp_begin
head -n $cpp_end Makefile | tail -n $diff | sed 's/-Dparallel/-Dparallel -Dtwoway/' >> Makefile.twoway
실패했기 때문에차이점동일한
1+73 IOAPI = -L$(LIB)/ioapi/lib -lioapi[1]-1-48 cpp_flags = \
71 CPP_FLAGS = $(cpp_flags)[1]
여기 난 기대하고 있어차이점꼬리에 사용되는 수치상의 차이가 있을 수 있습니다.