尝试使用windows批处理文件,在下面的代码中,我通过在www中搜索找到。
@ECHO OFF
REM Call this with two arguments, and it will add them.
SET a=%1+%2
IF %ERRORLEVEL%==0 (goto errors-0) ELSE (goto errors-1)
REM Instead of using goto with the variable, this uses an IF-ELSE structure
:errors-0
REM This is if it was successful
ECHO %a%
紧随其后
https://stackoverflow.com/questions/1809899/how-can-i-assign-the-output-of-a-function-to-a-variable-using-bash和如何将命令的输出分配给变量?
我写
function getos(){
# http://stackoverflow.com/a/27776822/1637673
case "$(uname -s)" in
Darwin)
OS='mac'
;;
Linu
如果我将cat命令保存到字符串中,然后执行它,那么我将得到一个错误。
linux# cmd="cat /data/test/test.tx* | grep toto"
linux# eval '$cmd'
cat: |: No such file or directory
cat: grep: No such file or directory
cat: toto: No such file or directory
即使是
linux# $cmd
cat: |: No such file or directory
cat: grep: No such file
在bash脚本中
if [ 1 ]
then
echo "Yes"
else
echo "No"
fi
输出:Yes
它表示“1”被视为真值。
但在代码中:
word = Linux
letter = nuxi
if echo "$word" | grep -q "$letter"
then
echo "Yes"
else
echo "No"
fi
输出:No
但是echo "$word" | grep -q "$letter"将返回1,那
~$ bash --version
GNU bash, version 5.1.12(1)-release (x86_64-pc-linux-gnu)
~$ alias bab=python
~$ $(echo bab)
bash: bab: command not found
我希望bab会变成"python",但看起来并非如此。
~$ $(echo alias)
alias bab='python'
alias ls='ls --color=auto'
~$ bab
Python 3.10.1 (main, Dec 11 2021, 17:2
下面的代码将导致'if‘语句提前退出,而不是在'if’块中执行'echo‘命令。我想知道为什么这只发生在'if‘块,而不是在脚本的主要部分。注意:我理解将':=‘改为’:‘将解决问题--我并不想修复这个问题,我希望了解'if’块的执行环境之间的区别,它首先导致了问题的发生。
#!/bin/bash
if true; then
VAR=${$1:='val'}
echo "This does not run"
fi
VAR=${$1:='val'}
echo
我这里有windows中的批处理文件,我想将同样的文件应用于linux。我可以请您帮助在linux中运行它吗?下面是windows的批处理文件:
@echo off
TITLE Upload Masterlist
set /p answer=Do you want continue? [Y/N]:
if %answer%==Y goto G
if %answer%==y goto G
if %answer%==N goto EndoF
if %answer%==n goto EndoF
:EndoF
goto:eof
:G
cls
set MYSQL_HOME=mysql>C:
我在尝试链接我的项目时遇到了麻烦:
arm-linux-gnueabihf/bin/ld: ~/libcrypto_t.a(mem_dbg.o): relocation R_ARM_THM_MOVW_ABS_NC against 'a local symbol' an not be used when making a shared object; recompile with -fPIC
libcrypto_t.a: could not read symbols: Bad value
所以我猜我没有把openssl构建为共享对象。我试着这样做
export cross=arm