ZKX's LAB

linux shell 脚本错误,帮忙解决 shell脚本最后的fi错误

2021-04-04知识0

shell脚本出错!来大神指出错误出处!!!! 1、只有数据的CSV文件,CSV file that includes only numbers.As an example,create a text file,named as 'data.csv' if you prefer,which includes the following data with any editor you like.[html]view plain copy1,2,3,45,6,7,89,0,1,21)Read all the data into a 3X4 matrix.[cpp]view plain copyMat=csvread('data.csv');disp(Mat);2)Read part of the data with specification of the start index.What is important is the data is accessed from index 0 in the direction of row and column.[html]view plain copyMat=csvread('data.csv',1,2);disp(Mat);Result showing below.[html]view plain copy7 81 23)Read only the specified range.[cpp]view plain copyMat=csvread('data.csv',0,1,[0,1,2,2]);disp(Mat);Note the starting index you specified in the second and third parameters is the same with the first two arguments in the fourth parameter matrix.2、How to read a CSV file containing string data items.Create a file,named as 'datastr.csv' if you like.Add the following data.[html]view plain copy1。

帮我看看这个简单的shell脚本哪里不对,报这个错误 把下面的复制一下就可以了,应该是格式问题bin/bashnum=10echo\"the number is:\"$numif[10-eq 10];thenecho\"equalelseecho\"not equalfi

shell脚本中如何获取错误输出 不太明白你表达的意思,是无法看到错误信息还是想保存错误信息?1、一般来讲,shell命令都是有错误输出的,它会打印在屏幕上,但实际上是标准错误输出文件,如果我不想输出到屏幕,而是写到文件里,我们可以用管道符'>;'重定向标准错误输出,比如:我cat一个不存在的文件,会有错误输出,我可以把错误重定向到文件里12345cat/tmp/aacat:/tmp/aa:No such file or directorycat/tmp/aa 2>;err.logcat err.logcat:/tmp/aa:No such file or directory2表示标准错误输出。另外,我甚至可以把错误输出放到shell变量里:123aa=$(cat/tmp/aa 2>;&1)echo$aacat:/tmp/aa:No such file or directory2>;&1表示,我把错误输出重定向到标准屏幕输出1上,在赋值给变量aa2、关于如何调试shell脚本很简单1sh-vx xxxx.sh上述命令会打印shell脚本的执行过程和结果,有助于排错。当然,某些情况下,可能不会有输出(如shell中有函数,可能就不会输出函数里的过程)。

#shell脚本最后的fi错误

随机阅读

qrcode
访问手机版