shell腳本mv報錯
① 上網抄了個shell腳本,因為是初學者,有如下報錯無法自己解決,跪求大牛指點,謝謝啦
不知道腳本是這樣寫的還是因為你復制的原因,這個是語法問題
第四行awk後面少了一個空格
第五行[]中,!前面要有空格,"後面也要有空格
② redhat系統的計劃任務執行腳本:shell腳本手動能成功,看日誌任務有執行,問題是只執行了一條mv語句
環境不一樣
手動的時候你是登錄了,載入了用戶的環境變數
計劃任務是不會去載入環境變數的
腳本最前面source一下環境變數試試看
. /etc/profile
. /etc/bashrc
自己看著加
③ shell腳本執行錯誤
你的rpm-file即$1參數是什麼呢?
報錯貌似是由於文件不存在啊
④ shell腳本這兩行代碼為什麼報錯呀
括弧寫多了,
$((i-1)),
雙括弧內部支持算術運算,內部變數不要再加$符號,你內部變數是一個數組而已,
$((i【0】-1)),
輸入法問題方括弧是中文,看明白結構一層層套就可以了
⑤ 如何使用shell腳本將一個目錄下大於某個數的文件mv到其他目錄下,為何如下的腳本實現不了。
find/home/sj/xxx/log/-size+20M-execmv{}/home/sj/xxx/test/;
直接用find很簡單,大於某個文件閥值使用-gt?
⑥ 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
1, 2, 3, 4
5, 6, 7, 8
9, 0, 1, 2
1) Read all the data into a 3X4 matrix.
[cpp] view plain
Mat = 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
Mat = csvread('data.csv', 1, 2);
disp(Mat);
Result showing below.
[html] view plain
7 8
1 2
3) Read only the specified range.
[cpp] view plain
Mat = 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
1, 2, 3, Mine
4, 5, 6, Yours
7, 8, 9, His
One who try to use csvread shall encounter frustration. :(
I propose another solution to solve this case.
[cpp] view plain
fid = fopen('datastr.csv');
dcells = textscan(fid, '%f, %f, %f, %s');
fclose(fid);
dcellneeds = dcells(1:3);
Mat = cell2mat(dcellneeds);
disp(Mat);
The result showing below.
[html] view plain
1 2 3
4 5 6
7 8 9
Try it and good luck. :)
⑦ 救急 shell腳本mv文件到指定uicc目錄
mv"$BUILD_OUT/telephony-common/smali/com/android/internal/telephony/AdnRecord$Injector.smali""$BUILD_OUT/telephony-common/smali/com/android/internal/telephony/uicc"
⑧ 問大家一個shell的簡單腳本問題,報錯了,我不知道為什麼報這個錯
還原一下腳本應該是這樣:
#!/bin/bash
#Part="/backup"
Look_out=`df |grep $Part|awk '{print $5}' |sed 's/%//g'`
echo $Look_out
until [ "$Look_out" -gt "0" ]
do echo "Filesystem /backup is nearly full" | mail root Look_out=`df |grep $Part|awk '{print $5}' |sed 's/%//g'`
sleep 3600
done
根據出錯信息很明顯,腳本名為9.sh,第6行,也就是until [ "$Look_out" -gt "0" ],出錯,有一個應該是整數類型的數據沒有正確出現。
個人分析,應該有2個問題:
------------------------------------------------------------
1) until [ "$Look_out" -gt "0" ]應該寫為until [ ${Look_out} -gt 0 ];
2)設置環境變數的時候#Part="/backup" 多加了#,這個設置不應該被注釋掉,後面的Look_out變數需要用到這個變數。