在linux中编写shell脚本的新手是一种新手。它是一个csh脚本,但我在bash shell中运行它,为什么我使用#!/bin/bash而不是#!/bin/csh。 1 #!/bin/bash
2 set i = 1
3 echo it starts
4
5 while ($i <= 5)
6 echo i is $i
7 @
我需要让我的输入有效并根据条件为真或假来接收有效的输出。在这里,即使我的条件是真的,我仍然会得到错误的结果。我的代码在哪里错了? #
set input
#read -p "Who wrote the book Roots?" : input
#echo Who wrote the book Roots?
#read input
if($input == "Alex Haley")
我正在尝试编写一个shell脚本。在那里,我从用户获得路径作为位置。我想知道它是否以'/'结尾。如果是这样,我必须将其删除并将其分配给另一个变量。 脚本我试图 #!/bin/csh
set loc="/home/user/"
if (("$loc" == */))
then
echo true
set b=${loc::-1}
echo $b
else