为了使我的代码可移植,我尝试使用printf而不是echo.但是之后
printf "-dogs-cats"
Run Code Online (Sandbox Code Playgroud)
返回错误.本案的解决方法是:
printf "-";printf "dogs-cats"
Run Code Online (Sandbox Code Playgroud)
但是有一个通用的,可移植的命令(或一个选项printf),它将打印任意字符串作为文字/逐字,而不是尝试将字符串解释为格式?
我在BSD UNIX(在Mac上)工作,但我的目标是在其他UNIX风格中也可以使用的代码.
在我的文档中,我想使用 ``` 块显示一些信息,例如:
```
bruin@c7 ~ $ cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)
bruin@c7 ~ $
```
Run Code Online (Sandbox Code Playgroud)
对于大的输出块,我想折叠它们。怎么做?在网上搜索似乎所有相关主题都是关于代码折叠的,但我想要折叠的不是任何类型的代码,只是简单的文本......
谢谢!
假设我们想从数据库中选择数据,然后我们为此编写查询.
例:
SqlConnection con=new SqlConnection(Connetion name)
string selectPkId = @"SELECT PK_ID FROM TABLE"
SqlCommand cmd=new SqlCommand(selectPkId ,con);
Run Code Online (Sandbox Code Playgroud)
所以,我的问题是为什么我们在sql查询之前基本上使用@.如果我之前没有使用@那么它再次正常工作(不会给出任何错误),那么使用"@"需要什么?请告诉我.
我有以下页面:
<h:form id="gameSelectionForm">
<h:selectOneMenu id="gameSelection">
<f:selectItems value="#{gameBean.gameIds}" />
</h:selectOneMenu>
<h:commandButton id="gameSelector" value="Play" action="#{gameBean.changeGame}" />
</h:form>
<h:panelGroup id="gameDiv">
<f:verbatim>
<iframe src="/levelup/resources/games/#{gameBean.gameId}/#{gameBean.htmlPage}" width="700px" height="800px" frameborder="0"/>
</f:verbatim>
</h:panelGroup>
Run Code Online (Sandbox Code Playgroud)
当我点击"gameSelector"按钮时,这里是事件序列:1.调用gameBean.getGameId和gameBean.getHtmlPage 2.调用gameBean.changeGame 3.刷新页面.
我的问题在于1.和2. changeGame修改了getGameId和getHtmlPage使用的gameBean变量.因此,我希望它首先执行,以便在刷新其他面板时,它们包含正确的数据.
请注意,此问题似乎只发生在gameDiv元素中的调用(其他变量已正确刷新).
您是否知道我可以做什么来恢复1.和2.的顺序,以便changeGame()方法是第一个被调用的?
我在Tomcat 7.0上使用JavaServer Faces 2.0.
提前致谢
这是Microsoft的代码示例,具有不同的文件位置,但不起作用:
string fileName = "test1.txt";
string sourcePath = @"C:\";
string targetPath = @"C:\Test\";
// Use Path class to manipulate file and directory paths.
string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
string destFile = System.IO.Path.Combine(targetPath, fileName);
System.IO.File.Copy(sourceFile, destFile, true);
Run Code Online (Sandbox Code Playgroud)
它找不到源文件.如果我设置了一个断点,这就是我得到的:
args {string[0]} string[]
fileName "test1.txt" string
sourcePath "C:\\" string
targetPath "C:\\Test\\" string
sourceFile "C:\\test1.txt" string
destFile "C:\\Test\\test1.txt" string
Run Code Online (Sandbox Code Playgroud)
因此,即使使用逐字字符串,它看起来也会加倍反斜杠.(毫无疑问,我在C中有一个test1.txt文件:)有什么想法吗?谢谢!
我想在Bash变量中存储逐字文本.我有一个这里描述的方法,我想批评和建议改进这种方法.目前,具体应用是在shell脚本库中具有某种程度上自我记录的功能.这是我想到的那种功能:
templateFunction(){
################################################################################
interrogationInformation=$(cat << 2012-09-26T1909
<class>
setup
</class>
<description>
This is a natural language description of this function.
</description>
<prerequisiteFunctions>
myFunction1
myFunction2
</prerequisiteFunctions>
<prerequisitePrograms>
myProgram1
myProgram2
</prerequisitePrograms>
2012-09-26T1909
)
################################################################################
if [ "${1}" != "-interrogate" ]; then #interrogation
echo "function template"
fi #interrogation
}
Run Code Online (Sandbox Code Playgroud)
询问函数可以查询模板函数,然后模板函数通过'verbatim'变量interrogationInformation返回有关自身的一些信息.询问功能解析此信息.
在适当的时候,可能会在这些"逐字"变量中存储特殊字符(如引号)(例如,用自然语言).这些变量也可用于构建代码文件,例如用于网页.使用这种方法的困难在于cat可能在不同的分布之间变化,并且所得到的行为可能是不可预测的.基本上,我想批评我的方法和改进建议.也许一个改进是比本例中使用的猫更好(最好是标准的)程序.
我非常感谢你的任何建议.
是否可以在逐字环境中创建一个带有参数的新命令和一些缩进?
\newcommand{codeblock}[1]{\begin{quote}\begin{verbatim}#1\end{verbatim}\end{quote}}
Run Code Online (Sandbox Code Playgroud)
这不起作用.还有其他方法吗?
string str1="xxx";
string str2=@"sss" + str1 + "ddd";
Console.WriteLine(str2);
Run Code Online (Sandbox Code Playgroud)
上面的代码给出:
sssxxxddd
但我想要的是:
sss" + str1 + "ddd
怎么做?
当我现在在使用jsf时,我想知道为什么我们在jsf中使用逐字标记,它的意义是什么?
任何帮助将不胜感激。