我有一个像下面的字符串,这是一个非常大的
http://i.imgur.com/4QjOLKC.png< - 它在粘贴命令时会像这样被卡住
$str="Hello this question is related to print a big line in a Unix file. this line is very long having more than 300 characters inside it. When I am running the below commands its failing because on a Unix session if we paste big commands it does not get pasted properly";
echo "Hello this question is related to print a big line in a Unix file. this line is very long having more than 300 characters inside it. When I am running the below commands its failing because on a Unix session if we paste big commands it does not get pasted properly" > file.txt
这个命令失败了,我也试过
cat > file.dat <<_EOF_ "Hello this question is related to print a big line in a Unix file. this line is v.....aste big commands it does not get pasted properly"
_EOF_
但它没有成功。由于整行太大,屏幕卡住了
我尝试了几个选项 http://www.guguncube.com/2140/unix-set-a-multi-line-text-to-a-string-variable-or-file-in-bash 但没有奏效
答案 0 :(得分:0)
如果您在bash
,请先执行:
shopt -s checkwinsize
然后:
str=$(cat <<EOF
"Hello this question is related to print a big line in a Unix file. this line is very long having more than 300 characters inside it. When I am running the below commands its failing because on a Unix session if we paste big commands it does not get pasted properly"
EOF
)
指示插入文件:
cat <<EOF >file.txt
"Hello this question is related to print a big line in a Unix file. this line is very long having more than 300 characters inside it. When I am running the below commands its failing because on a Unix session if we paste big commands it does not get pasted properly"
EOF
如果每件事都失败使用escape
字符打破分段。
cat <<EOF >file.txt
"Hello this question is related to print a big line in a Unix file. this \
line is very long having more than 300 characters inside it. When I am \
running the below commands its failing because on a Unix \
session if we paste big commands it does not get pasted properly"
EOF