我可以告诉你这是我很长时间以来见过的最疯狂的事情。
我在CentOS 5.4上运行了以下sh脚本:
# Check GOLD_DIR`
echo $GOLD_DIR"<--"
#export GOLD_DIR=/share/apps/GOLD_Suite/GOLD <uncommenting this line works!!
if [ "X$GOLD_DIR" = "X" ] ; then
echo "ERROR: GOLD_DIR is (probably) not set on host ${HostName}
经过几天的研究,我仍然不明白为什么:
echo -e a\nb
给我一个输出: anb
而
echo -e 'a\nb' -----> Gives me an output of
a
b
我理解echo -e激活了转义序列,所以它应该在第一个示例中工作,但它不..我迷路了。我在Ubuntu和OpenSuse中尝试了相同的命令。都是一样的结果。有什么帮助吗?
只有在目录存在的情况下,我才试图在目录中找到最近的子文件夹。当我在FOR语句中使用IF循环时,我的代码不会给我任何输出。这是我的密码-
@echo off
IF EXIST "D:\MyDirectory" (
FOR /F "delims=" %%i IN ('dir "D:\MyDirectory" /b /ad-h /t:c /od') DO SET abc=%%i
echo Most recent subfolder: %abc%
) ELSE (
echo Directory not found
我正在尝试通过批处理文件创建vbs。但是有一行我包含了一个对象。批处理文件无法将右括号)写入vbs,这导致在运行vbs时出现错误。
批处理文件编码为:
echo Set oShell = CreateObject("WScript.Shell") >> zipIt.vbs
输出:
echo Set oShell = CreateObject("WScript.Shell"
) 1>>zipIt.vbs
The process cannot access the file because it is being used by anoth
当我试图用*在shell.The代码中输出一些模式时,我感到非常困惑:
#!/bin/bash
for i in {1..10}
do
tmpstr=""
for ((c=1;c<=i;c++))
do
tmpstr=$tmpstr'*'
done
echo $tmpstr #add some string after tmpstr will work
done
输出显示了ls命令在每一行中的结果,这是意外的。如果我在echo $tmpstr.For示例之后添加任何字符串,echo $tmp
我有一个输出消息的perl脚本。GNU正在调用此脚本。在我的GNU中,我希望显示由脚本打印出来的消息,并将其存储在一个变量中。
我就是这样做的。
result=`$(PERL) parse.pl report.log` #parse the report
echo $(result) #echo the message here
ifneq ($(strip $$(result)),) #check if message is empty
#if not empty, search for filepath string pattern and exit
echo filep
我正在尝试使用,但它似乎并不适用于我:
$ cat Makefile
define foo =
I'm a little teapot
short and stout
here is my handle
here is my spout
endef
all:
echo "$(foo)"
$ make all
echo ""
$ make --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see th
以前从未编写过任何shell脚本,但在大量搜索之后,我为我的docker文件编写了以下代码。但不明白为什么它不起作用。
###stage 2####################
FROM nginx:alpine
##########Calculate the environment type #########
ARG BUILD_TYPE
####echo of build build_type does gives me output of Development when passed argument is Development.
RUN if [ "$BUILD_