English 中文(简体)
我如何将 CRLF 或其他无法打印的字符 嵌入我的外壳脚本?
原标题:How do I embed CRLF or other unprintable characters in my shell script?

我上司向我提出一个问题,即如何以合理的便携和稳健方式将CRLF序列嵌入其外壳脚本(用于通过某种他正在做的 < code>netcat 或 telnet 东西插入其外壳脚本)。

问题回答

假设POSIX是“足够便携式”的良好基线,

printf "
"

我对他的建议是:

#!/bin/sh
crlf="$(echo xy | tr xy  
 )"

... 但我可以接受其它评论。 GNU < code> tr 和 bash 的现代版本当然可以。





相关问题
KornShell- Creating a fixed width text file

I need to create a simple fixed width text file in KornShell (ksh). My current attempt using printf to pad the string isn t working out very well. What s the shortest, cleanest way to create a fixed ...

unix find command

how to use the find command to find files/directories which are not matching the pattern. for eg: find <some options > -name "dontfile.txt" should give me output of all the find whose file ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Case insensitive comparison of strings in shell script

The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this?

1. 露台式照像

在Windows XP中,没有一时出现指挥时,是否有办法操作一种灰色文字? 我常常需要把“善待”(工作)与“灰色”同起来,即使我的文字没有产出,......

热门标签