[英]How can I create a cover-page style text file via Linux script?
首先,我想指出的是,對於Linux腳本,我是一個完全的菜鳥,但是我試圖通過腳本創建封面,而在格式化方面完全迷路了。
到目前為止,我有
#!/bin/bash
studentName = "Jeremy"
studentNum = "0281190"
courseSection = "702"
read -p "Please enter Course Name: " courseName
read -p "Please enter Course Number: " courseNum
read -p "Please enter Instructor Name: " instrutorNam
read -p "Please enter Submission Date: " subDate
read -p "Please enter Submission Title: " subName
read -p "Submission Subject: " subSubject
touch CoverPage.txt
echo $subName $subDate >> CoverPage.txt
我想要做的是讓用戶輸入封面中包含的主要信息,但是到目前為止,我最終獲得的最佳輸出只是混亂不堪。
由於不清楚,請事先道歉,只是不確定從哪里開始。
此bash功能將使屏幕上所有文本居中:
ctr() { s="$*"; width=$(( ($COLUMNS + ${#value})/2 )); printf "%${width}s\n" "$s"; }
如果您不希望文本在屏幕上居中,而是根據某些指定的寬度居中,則用該寬度替換$COLUMNS
。
示例(位於我的終端而非您的瀏覽器上):
$ ctr Hello World
Hello World
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.