<style>
.blue{
color:#4A919E
}
h1{
font-size:100%;
}
h2{
}
</style>
# <div style="font-size:60%">如何利用<br>Shell Script<br>製作測資檔</div>
>[name=林德恩]
---
## 測資
<!--
* 測試資料的簡稱
* 程式是否與預期達到效果相同
-->
----
### 測資製作
----
* C / C++
* Python
* ~~手動輸入~~
* 其他方法
----
### 測資輸出
----
#### Unix 環境下
```=
編出來的執行檔 <輸入的文字檔 >輸出的文字檔
#也可
編出來的執行檔 < 輸入的文字檔 > 輸出的文字檔
# 會產生一個文字檔
編出來的執行檔 <輸入的文字檔
# 直接顯示
```
----
範例:
```=
a.out <input.txt >output.txt
# 產生一個 output.txt
hw0102 <hw0102_00.in >hw0102_00.out
# 產生一個 hw0102_00.out 的文字檔
```
----
#### C: freopen
```c=
freopen("輸入的文字檔", "r", stdin);
freopen("輸出的文字檔", "w", stdout);
```
----
### 比較測資
```shell=
diff 自己的輸出測資 別人的輸出測資
```
----
範例:
```shell=
diff hw0304-1_00.out hw0304-1_00.out
```
---
## Shell Script
----
範例
`test.sh`
```=
#!/binsh
for n in$(seq 1 5);
do
./hw0201 <./test${n}.in >output${n}.out
done
```
----
記得要加執行權限
```
chmod +x 所寫的檔案
```
---
## 參考資料
[AP325](https://drive.google.com/drive/folders/10hZCMHH0YgsfguVZCHU7EYiG8qJE5f-m)
[iThome - \[Day 18\] 自己的 Shell Script 自己寫 - 介紹篇](https://ithelp.ithome.com.tw/articles/10224799)
{"description":"行動應用與網路工具","title":"大學入門","slideOptions":"{\"theme\":\"moon\",\"transition\":\"fade\"}","contributors":"[{\"id\":\"bd47cc0a-d3e4-4997-b042-3ae3230b8982\",\"add\":1758,\"del\":562}]"}