如何在不解析的情况下写入 bash 中的文件?
How to write to file in bash without parsing?
尝试在 bash 中编写以下命令时,使用 /etc/languagetools/language_tool.sh
中文件的可变路径:
java -jar /path/to/languagetools/languagetool-commandline.jar "${@:1}"
我在阻止对 "${@:1}"
进行评估时遇到了一些困难。执行解析的函数包含:
#!/bin/bash
some_function() {
local create_target_file=$(sudo touch
$LANGUAGE_TOOL_TARGET_DIR/$LANGUAGE_TOOL_CONTROL_SCRIPTNAME)
local make_readable=$(chmod 777 $LANGUAGE_TOOL_TARGET_DIR/$LANGUAGE_TOOL_CONTROL_SCRIPTNAME)
command_one="java -jar
$LANGUAGE_TOOL_TARGET_DIR/$LANGUAGE_TOOL_SNAPSHOT_DIRNAME/$LANGUAGE_TOOL_TARGET_FILENAME "
command_two='${@:1}'
local write_content_to_file=$(sudo sh -c "echo $command_one$command_two > $LANGUAGE_TOOL_TARGET_DIR/$LANGUAGE_TOOL_CONTROL_SCRIPTNAME")
}
哪个returns:
sh: 1: Bad substitution
因此,我很好奇,如何将命令字符串写入文件,而不解析命令中的内容?
您不需要命令替换或变量赋值。刚刚
echo "$command_one$command_two" > "$LANGUAGE_TOOL_TARGET_DIR/$LANGUAGE_TOOL_CONTROL_SCRIPTNAME"
尝试在 bash 中编写以下命令时,使用 /etc/languagetools/language_tool.sh
中文件的可变路径:
java -jar /path/to/languagetools/languagetool-commandline.jar "${@:1}"
我在阻止对 "${@:1}"
进行评估时遇到了一些困难。执行解析的函数包含:
#!/bin/bash
some_function() {
local create_target_file=$(sudo touch
$LANGUAGE_TOOL_TARGET_DIR/$LANGUAGE_TOOL_CONTROL_SCRIPTNAME)
local make_readable=$(chmod 777 $LANGUAGE_TOOL_TARGET_DIR/$LANGUAGE_TOOL_CONTROL_SCRIPTNAME)
command_one="java -jar
$LANGUAGE_TOOL_TARGET_DIR/$LANGUAGE_TOOL_SNAPSHOT_DIRNAME/$LANGUAGE_TOOL_TARGET_FILENAME "
command_two='${@:1}'
local write_content_to_file=$(sudo sh -c "echo $command_one$command_two > $LANGUAGE_TOOL_TARGET_DIR/$LANGUAGE_TOOL_CONTROL_SCRIPTNAME")
}
哪个returns:
sh: 1: Bad substitution
因此,我很好奇,如何将命令字符串写入文件,而不解析命令中的内容?
您不需要命令替换或变量赋值。刚刚
echo "$command_one$command_two" > "$LANGUAGE_TOOL_TARGET_DIR/$LANGUAGE_TOOL_CONTROL_SCRIPTNAME"