2013-07-27 1 views
2

문자열에 문자 :추가 ''내가 문자열 변수이 bash는 명령을 저장할

 
find /Users/memmaker6501/Desktop/ -name "*\[*\]*" -type d >> busqueda.txt 

을하지만 순서와 오류를 얻은 \]

를 저장하는 방법이있다 문자열에 \]?

+0

@YuHao는 내가 알고있는 것처럼, 그는 C++ 표준 : : 문자열이나'const를 숯불 * '로 그 명령을 저장하려고합니다. –

+0

@ NikosC 그래도 [tag : C++] 태그는 보증하지 않습니다. –

+0

@ColeJohnson 나는 그것이 bash가 아닌 C++에서 따옴표를 벗어나는 방법이기 때문에 생각합니다. 음, 적어도 그것이 내가 질문을 이해하는 방법이다 :-) –

답변

4

특수 문자 앞에 \을 입력하십시오. 마찬가지로이 "find /Users/memmaker6501/Desktop/ -name \"*\\[*\\]*\" -type d >> busqueda.txt"

+0

그건 내 날을 저장한다. 감사. –

+0

기꺼이 도와 드리겠습니다. :) –

4

백 슬래시와 큰 따옴표과 같이, 백 슬래시로 이스케이프해야합니다

"find /Users/memmaker6501/Desktop/ -name \"*\\[*\\]*\" -type d >> busqueda.txt" 

Escape sequences in C++ strings :

Escape 
sequence Description      Representation 

\'   single quote     byte 0x27 
\"   double quote     byte 0x22 
\?   question mark     byte 0x3f 
\\   backslash      byte 0x5c 
\0   null character     byte 0x00 
\a   audible bell     byte 0x07 
\b   backspace      byte 0x08 
\f   form feed - new page   byte 0x0c 
\n   line feed - new line   byte 0x0a 
\r   carriage return     byte 0x0d 
\t   horizontal tab     byte 0x09 
\v   vertical tab     byte 0x0b 
\nnn  arbitrary octal value   byte nnn 
\xnn  arbitrary hexadecimal value  byte nn 
\unnnn  arbitrary Unicode value.  code point U+nnnn 
\Unnnnnnnn arbitrary Unicode value.  code point U+nnnnnnnn 
3

C++ (11)는 복잡한 문자열 식을 만드는 단순화하는 원시 문자열 리터럴이있다 .

R"***(find /Users/memmaker6501/Desktop/ -name "*\[*\]*" -type d >> busqueda.txt)***" 
+0

정보를 제공해 주셔서 감사합니다. –