This topic created in 5161 days ago, the information mentioned may be changed or developed.
test.txt 文件:
Hello
World
!
test.sh 文件
#! /bin/sh
test()
{
echo $1
}
test "`cat test.txt`"
执行 ./test.sh 后显示
Hello World !
为什么?能不能原样获取传进来的参数?
6 replies 1970-01-01 08:00:00 +08:00  | | 1 feiandxs Mar 10, 2012 回车如果表示换行可以用\n代替的吧 还没听说过可以直接获取其他文件里的换行标记的方法 |
 | | 3 YUCOAT Apr 20, 2012 这样就可以了:
#!/bin/bash
test () { echo "$*"; }
test "$(echo -e "hello\nworld!\n")" |
 | | 4 jkeylu Apr 20, 2012 via Android |
 | | 5 yangg Apr 20, 2012 echo "$1"加引号即可 |