我正在尝试创建一个 spritz 应用程序。一切正常,但从昨天开始,我不断收到此错误:
./spritz:第 176 行:语法错误:文件意外结束
我检查了脚本文件,一切似乎都很完美。我很困惑,我终于有了一个 if 语句,它看起来是正确的!这是最后一部分:
#checks if speed is 150
157 if [[ $2 -eq 150 ]];
158 then
159 starttime=$SECONDS
160 FS=$'\n'
161 for j in `grep --color=always -iP '\b[^aeiou\s]*[aeiou][^aeiou\s]*\K[aeiou]' $1`;
162 do
163 #Reads the text file in the centre of the screen
164 echo " ___________________"
165 echo " $j";
166 echo " ___________________"
167 echo " Speed 150 wpm"
168 sleep 0.9;
169 clear;
170 done
171 endtime=$(($SECONDS - $starttime))
172 echo …
Run Code Online (Sandbox Code Playgroud) 我有一个名为“list”的文本文件,其中包含一些随机单词:
he
she
we
his
her
with
his this this -- this
this
Run Code Online (Sandbox Code Playgroud)
我运行了这个 sed 命令:
sed '1,4p' list
Run Code Online (Sandbox Code Playgroud)
我认为这个 sed 命令要做的是列出这个文件中的前 4 个单词,所以我认为输出是:
he
she
we
his
Run Code Online (Sandbox Code Playgroud)
但是输出是这样的:
he
he
she
she
we
we
his
his
her
with
his this this -- this
this
Run Code Online (Sandbox Code Playgroud)
谁能告诉我我做错了什么或为什么输出不同?
我知道问号被认为是一个特殊的字符,它具有特殊的含义。问号代表可以是任何类型的单个字符。
在我的实践课中,我们有一个例子:
ls ?
Run Code Online (Sandbox Code Playgroud)
这将搜索仅包含一个字符的所有文件。我想知道如何搜索特定数量的字符。例如:我如何找到只有 3 个字符的文件名?