상황
리눅스 환경에서 azure cli 사용중에 발견 한것
azure가 ms에서 제작해서 그런건지 windows타입의 개행문자가 들어 있었다
변수의 값은 이렇게 들어 있다
echo $eventhubNameSpaceResource
/subscriptions/0000/resourceGroups/sample/providers/Microsoft.EventHub/namespaces/sample-ns2
첫시도
eventhubPrivateLink=\`az network private-endpoint create -g $azRGName \
-n $azPEConnectionName \
--vnet-name $azVnetName \
--subnet $azSubnetName \
--private-connection-resource-id $eventhubNameSpaceResource \
--group-id namespace \
--connection-name $azPEConnectionName \
-l $azRGLocation`
(문서대로 옵션에 맞는 값을 넣었지만 오류 발생)
ERROR: (InvalidResourceId) String /subscriptions/0000/resourceGroups/sample/providers/Microsoft.Event is not a valid resource ID.le-ns2
Code: InvalidResourceId
Message: String /subscriptions/0000/resourceGroups/sample/providers/Microsoft.EventHub/namespaces/sam is not a valid resource ID.
두번째
eventhubPrivateLink=\`az network private-endpoint create -g $azRGName \
-n $azPEConnectionName \
--vnet-name $azVnetName \
--subnet $azSubnetName \
--private-connection-resource-id /subscriptions/0000/resourceGroups/sample/providers/Microsoft.EventHub/namespaces/sample-ns2 \
--group-id namespace \
--connection-name $azPEConnectionName \
-l $azRGLocation`
(잘 된다)
뭐가 다른걸까
echo $eventhubNameSpaceResource > test1.txt
echo /subscriptions/0000/resourceGroups/sample/providers/Microsoft.EventHub/namespaces/sample-ns2 > test2.txt
diff test1.txt test2.txt
(분명 똑같은 내용이지만 다르다고 나온다)
1c1
< /subscriptions/0000/resourceGroups/sample/providers/Microsoft.EventHub/namespaces/sample-ns2
---
> /subscriptions/0000/resourceGroups/sample/providers/Microsoft.EventHub/namespaces/sample-ns2
vi test1.txt
"test1.txt" [dos] 1L, 94C
vi test2.txt
"test2.txt" 1L, 93C
(눈에 띄는 차이 -> [dos] 표시 & 1c 차이)
16진수로 확인하기
- vi 명령모드에서 %!xxd 를 입력하여 hex 모드로 들어간다
- 둘의 차이는 OS별 개행문자 처리 방법이다.
[ DOS ]
00000000: 2f73 7562 7363 7269 7074 696f 6e73 2f30 /subscriptions/0
00000010: 3030 302f 7265 736f 7572 6365 4772 6f75 000/resourceGrou
00000020: 7073 2f73 616d 706c 652f 7072 6f76 6964 ps/sample/provid
00000030: 6572 732f 4d69 6372 6f73 6f66 742e 4576 ers/Microsoft.Ev
00000040: 656e 7448 7562 2f6e 616d 6573 7061 6365 entHub/namespace
00000050: 732f 7361 6d70 6c65 2d6e 7332 0d0a s/sample-ns2..
[ Linux ]
00000000: 2f73 7562 7363 7269 7074 696f 6e73 2f30 /subscriptions/0
00000010: 3030 302f 7265 736f 7572 6365 4772 6f75 000/resourceGrou
00000020: 7073 2f73 616d 706c 652f 7072 6f76 6964 ps/sample/provid
00000030: 6572 732f 4d69 6372 6f73 6f66 742e 4576 ers/Microsoft.Ev
00000040: 656e 7448 7562 2f6e 616d 6573 7061 6365 entHub/namespace
00000050: 732f 7361 6d70 6c65 2d6e 7332 0a s/sample-ns2.
HowTo?
https://stackoverflow.com/questions/33506553/dos2unix-in-a-variable
파일의 경우에는 unix2dos/dos2unix 라는 유틸이 있다
하지만 내가 원하는건 변수를 unix 타입으로 변형시키고자 하는것
dos2unix 를 사용하여 변수도 처리할수 있지만... 이것때문에 설치하는건 이상한 처리 방법 같아서 좀더 찾아보니 다양한 방식으로 해결이 가능 했다.
variable_out=${eventhubNameSpaceResource//$'\r'/}
'공부하면서 > 기타' 카테고리의 다른 글
[react] * Module not found: Error: Can't resolve (1) | 2023.10.17 |
---|---|
[Maven] Error injecting: org.apache.maven.wagon.providers.http.HttpWagon (0) | 2023.06.13 |
[Linux] nslookup (0) | 2022.11.11 |
[Maven] Failed to clean project: Failed to delete (0) | 2022.11.07 |
SSH 자동인증 (0) | 2022.10.24 |