我正在努力在 Open SuSE 上创建自解压 shell 脚本。我引用这个链接。我的代码如下所示 -
#!/bin/bash
function die ()
{ echo "Error!";
exit 1 ;
}
echo Extracting...
# Script will need to find where is the archive. So search for "ARCHIVE" in this script and
# save the line number
archive=$(grep --text --line-number 'ARCHIVE:$' $0)
echo $archive
tail -n +$((archive + 1)) $0 | gzip -vdc - | tar -xvf - > /dev/null || die
echo Extraction completed
exit 0
ARCHIVE:
在我执行上面的脚本后,我得到了下面的输出。我认为这是不正确的并导致错误。
Extracting...
22:ARCHIVE:
./symhelp_self_extract.sh: line 16: 22:ARCHIVE:: syntax error in expression (error token is ":ARCHIVE:")
gzip: stdin: unexpected end of file
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
Error!
谁能解释这是什么语法错误?
谢谢,
欧姆基