我们可以将文件的内容附加到 Korn shell 中的变量值吗?如何?
/bin/ksh
:
$ B.11.31 Oct 1 2008 01:54:10 $
Version 11/16/88
blok.c $Date: 2008/08/20 12:15:51 $Revision: r11.31/1 PATCH_11.31 (PHCO_38683)
expand.c $Date: 2008/10/28 10:48:37 $Revision: r11.31/1 PATCH_11.31 (PHCO_38683)
builtin.c $Date: 2007/10/25 15:12:29 $Revision: r11.31/1 PATCH_11.31 (PHCO_37285)
test.c $Date: 2008/05/01 15:55:23 $Revision: r11.31/1 PATCH_11.31 (PHCO_38162)
strdata.c $Date: 2008/08/25 18:24:40 $Revision: r11.31/1 PATCH_11.31 (PHCO_38683)
$Revision: @(#) ksh88 R11.31_BL2009_0729_2 PATCH_11.31 PHCO_38683
所需输出
user@hostname>echo $somevariable value_stored_in_variable
user@hostname>cat somefile value_stored_in_file
user@hostname>append operation
user@hostname>echo $somevariable
value_stored_in_variablevalue_stored_in_file
答案1
myhost_2:home/myself $ cat /dev/null > Test3.txt
myhost_2:home/myself $ cat Test3.txt
myhost_2:home/myself $ pwd >> Test3.txt
myhost_2:home/myself $ cat Test3.txt
/home/myself
myhost_2:home/myself $ SOME_VARIABLE=abc
myhost_2:home/myself $ echo $SOME_VARIABLE
abc
myhost_2:home/myself $ SOME_VARIABLE=${SOME_VARIABLE}`cat Test3.txt`
myhost_2:home/myself $ echo $SOME_VARIABLE
abc/home/myself
但应该用引号引起来
echo "${stringvar}`cat ${CURRENT_PROJECT_SCRIPT_GREPPED}_grepped.txt`"