Todd Schneider는 그의 작업에서 다음 명령을 사용했습니다.뉴욕시 택시 데이터 분석PostresSQL용 CSV 파일을 준비합니다.
sed $'s/\r$//' $filename | sed '/^$/d' | ...
두 번째 sed 명령은 빈 줄을 제거합니다. 첫 번째는 무엇을 합니까?
답변1
에 따르면 man bash
:
Words of the form $'string' are treated specially. The word expands to string, with backslash-escaped characters replaced as specified by the ANSI C standard. Backslash escape sequences, if present, are decoded as follows: \a alert (bell) \b backspace \e \E an escape character \f form feed \n new line \r carriage return \t horizontal tab \v vertical tab \\ backslash \' single quote \" double quote \? question mark \nnn the eight-bit character whose value is the octal value nnn (one to three digits) \xHH the eight-bit character whose value is the hexadecimal value HH (one or two hex digits) \uHHHH the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value HHHH (one to four hex digits) \UHHHHHHHH the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value HHHHHHHH (one to eight hex digits) \cx a control-x character The expanded result is single-quoted, as if the dollar sign had not been present.
따라서 $'s/\r$//'
줄 끝에서 ASCII를 제거하십시오. CR
이는 Windows 줄 종결자를 UNIX 줄 종결자로 변환하는 조잡한 방법입니다.