好吧。我又一次把头撞到Linux墙上了。我在这里做错了什么:
#! /bin/bash
echo
echo "1. Windows (Microsoft)
echo 2. Linux (Red Hat)
echo 3. MacOS (Apple)
echo
echo -n Select your OS choice [1, 2 or 3]: "
READ OS
echo
if [ "$OS" -eq 1 ]; then
echo "You picked Windows (Microsoft)."
fi
if [ "$OS"
我有下面的脚本,我想用它来比较一个float和另一个给定的float。
#!/bin/sh
echo 'Enter a real number'
read n
echo n=$n
if (( $(echo "$n > 0.0" |bc -l) ))
then
echo 'n is +ve'
elif (( $(echo "$n < 0.0" |bc -l) ))
then
echo 'n is -ve'
else
echo 'n is zero'
fi
这在我的
我有一个简单的脚本如下。
names=("windows" "ubuntu" "raspbian" "debian" "kali linux")
echo "names array length: ${#names[@]}"
for n in ${names[@]}; do
echo $n
done
我的意图和希望是:
names array length: 5
windows
ubuntu
raspbian
debian
kali linux
但结果却是:
names array len
这是保存在文件中的前缀
wolf@linux:~$ cat prefix.txt
A.
B.
C.
wolf@linux:~$
我想将它与另一个输入(以版本格式)合并。
这是示例输入AB_CD_EF,但是它是水平格式的。
因此,我使用tr将其改为垂直格式。
wolf@linux:~$ echo AB_CD_EF | tr _ '\n'
AB
CD
EF
wolf@linux:~$
如何合并这两个输出以生成:
A. AB
B. CD
C. EF
我一直在考虑使用paste,但是它不适用于stdin。
wolf@linux:~$ paste $(echo AB_CD_E
我在学巴什。在做一个练习时,我犯了一个错误
ifs脚本要求选择,然后显示3条消息中的一条。该错误发生在选择之后。
#!/bin/bash
#nested ifs. script give user option to choose an OS.
osch=0
echo "1.Mac"
echo "2.Linux"
echo -n "Select your OS choice [1 or 2]? "
read osch
if [ $osch -eq 1 ] ; then
echo "You pick up Mac"
else ###
我知道有关这件事的多个问题,但这个问题似乎不同。这是PXE引导服务器提供的Grub配置:
net_ls_addr
sleep -i 5
set retcode=$?
clear
if [ $retcode == 1 ]; then
quit
fi
if [ $retcode == 0 ]; then
quit
fi
if [ $retcode == 3 ]; then
terminal_output gfxterm
set gfxmode="800x600;640x480;auto"
set theme=theme.txt
fi
menuentry '
THis是我的代码
for /l %%i in (1, 1, %N%) do (
echo !v%%i!
for /f "tokens=* delims=" %%l in ("!v%%i!") do (
echo %%l >> Linux.cpp )
)
在这里,我想将%%l中的数据复制到linux.cpp文件中,如果%%l包含abc.cpp,则此名称存储在linux.cpp中。在这里,我想将abc.cpp中的内容存储到linux.cpp。
请帮帮忙
kernel=`uname -s` # Current Kernel name
user=`whoami` # Current Unix username
time=`date +%H:%M` # Output current time
current_dir=$(pwd) # Shell's current location
script_dir=$(dirname $0) # This script's current location
# This if statement is to know the cor
我这里有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:
最近,我忙于在我的linux操作系统上使用bash,我也在使用它对文件进行排序。但这似乎并不管用。我所做的事情有没有另一种方式,或者它是错的? echo -n "Are you sure you would like to delete this/these files? [y/n]"
if [ $answer == "y" ]; then
echo -n "Which File would you like to delete?"
rm $answer
else
echo "canceled!"
fi
我创建了一个简单的bash脚本来创建一个混合的iso。但是当我尝试运行它时,我得到了输出:
hybridiso.sh: line 58: syntax error: unexpected end of file.
我已经检查了脚本并尝试对其进行更改,但仍然得到了相同的输出。剧本怎么了?
#!/bin/bash
##Sanity Cheks##
if [ "$(whoami)" != root ]; then
echo "You must be root to execute this script."
fi
if [ ! -x /usr/bin/xo