나는 bash는 스크립트에서이 같은 긴 명령을 포함하고 싶습니다 : 헤어 졌 긴 파일 이름bash에서 매우 긴 문자열 리터럴을 어떻게 분할합니까?
mycommand \
--server myserver \
--filename extremely/long/file/name/that/i/would/like/to/be/able/to/break/up/if/possible \
--otherflag \
--anotherflag
합니다.
# Insufficiently pretty
mycommand \
--server myserver \
--filename extremely/long/file/name/\
that/i/would/like/to/be/able/to/break/\
up/if/possible \
--otherflag \
--anotherflag \
을하지만 흐름을 나누기 :
나는이 작업을 수행 할 수 있습니다. 나는 처럼이 쓸 수 있어야하는 것입니다 :
# Doesn't work
mycommand \
--server myserver \
--filename extremely/long/file/name/\
that/i/would/like/to/be/able/to/break/\
up/if/possible \
--otherflag \
--anotherflag
을하지만 리터럴 문자열을 나누기 때문 작동하지 않습니다.
bash에 문자열 리터럴을 위반하지만 앞에 오는 공백을 무시하도록하는 방법이 있습니까?
좋은 아이디어. 'file = $ {file}/... '대신에'+ ='연산자를 사용하여 더 깔끔하게 만들 수 있습니다. – Chriszuma
+1 : 이것은 제 의견으로는 가장 모호한 접근법입니다. 그 의도는 분명합니다. –
@Chriszuma 그렇습니다. 배쉬가'+ = '연산자를 허용한다는 것을 잊었습니다. 나는 내 대답을 편집했다. – WilQu