shell基础二十篇 一些笔记
shell基礎二十篇
轉自?http://bbs.chinaunix.net/thread-452942-1-1.html
?
?研討:Bash 內建命令 read
(read命令更具體的說明見博客收藏的一篇:http://www.cnblogs.com/xiangzi888/archive/2012/03/27/2420084.html)
read -p "how old r u? " age
echo $age
read -p "some words? " -a words
echo ${words[*]}
read -p "Password: " -s passwd
echo $passwd
read -t 5 auth
echo $auth
read -n 1 key
read -dq -p "input something end with q: " menu
read -e file #在這試試命令歷史和補齊功能
?
我認為read ?很好用,比echo "input:";read input...用簡便!像這樣:
read input?"input:"
echo $input
而且read a b c這樣用也很實用:
echo -n "please year month day"
read a b c
echo $a $b $c
另外就是read讀fd,比如常用的兩個文件的拼接:
while read -u3 i && read -u4 j;do
echo $i $j
done 3<afile 4<bfile
?
sed '1,3d' quote.txt ?刪除1-3行。
sed '/Neave/d' quote.txt ?刪除所有包含Neave的行。
sed 's/splendid/SPLENDID/w sed.out' quote.txt ? ?替換并將結果寫到文件sed.out中。
?
轉載于:https://www.cnblogs.com/ph829/p/4648117.html
總結
以上是生活随笔為你收集整理的shell基础二十篇 一些笔记的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: dz47LE-125&nbsp;
- 下一篇: 请求帮助,消防环形车道距建筑物中心点距离