請下這個指令
du -B M . --max-depth=1 | sort -g
http://nathanmint.pixnet.net/blog/post/178733376-linux---du%E6%8C%87%E4%BB%A4-:-%E6%AA%A2%E6%9F%A5%E5%90%84%E5%80%8B%E8%B3%87%E6%96%99%E5%A4%BE%E7%9A%84%E6%AA%94%E6%A1%88%E5%A4%A7%E5%B0%8F%EF%BC%9B
這是我的工作酸甜苦辣,與大家分享,希望彼此都有收穫:) This is my working experience in my life. It is good to share with you :)
Showing posts with label terminal. Show all posts
Showing posts with label terminal. Show all posts
Thursday, March 24, 2016
Monday, September 7, 2015
ftp upload script in linux
#!/bin/sh
#!/usr/bin/expect
HOST='xxxxx'
USER='xxxxx'
PASSWD='xxxxx'
if [ $# -ne 1 ]; then
#echo "$#"
echo "Usage: ./upload_hwrd.sh [git repository name]"
exit
fi
# copy INET git repository to HWRD
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
cd /proj/d_01036/repo/
bin
put $1
quit
END_SCRIPT
echo "Copy $1 to /proj/d_01036/repo/ successfully"
exit
#!/usr/bin/expect
HOST='xxxxx'
USER='xxxxx'
PASSWD='xxxxx'
if [ $# -ne 1 ]; then
#echo "$#"
echo "Usage: ./upload_hwrd.sh [git repository name]"
exit
fi
# copy INET git repository to HWRD
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
cd /proj/d_01036/repo/
bin
put $1
quit
END_SCRIPT
echo "Copy $1 to /proj/d_01036/repo/ successfully"
exit
Tuesday, August 18, 2015
dynamic watch the log results
When your log continue to generate new results, you can use the following command in Linux console/terminal to see the last results every 1 second
- watch -n 1 tail [file name]
Monday, April 14, 2014
Wednesday, March 12, 2014
叫出系統管理員權限的終端機(Terminal)
(以win 7畫面為例)
執行步驟:
1.在任意Windows畫面下,先按鍵盤的"Windows功能鍵" + "r",會出現左下角的執行畫面
2. 鍵入cmd,再點選"確定",即可叫出在系統管理員狀態下的終端機(Terminal)
Thursday, March 6, 2014
Friday, February 21, 2014
Linux常用指令集 (Linux/Unix command sets)
這邊不多說,相信開始使用Linux系統後,一定感覺不像Windows那麼方便,滑鼠多點幾就搞定。為了適應這個強大的作業系統,使用終端機(Terminal)指令來控制一定是免不了的,而傻孩子我也相信大多人一定跟我一樣陷入了指令使用的迷思,所以這邊列舉幾個常用的重要指令,希望能為大家指點迷津,也供本人複習之用
常用指令
Example:
Example:
Example:
常用指令
- ls: 檢視目錄 [link]
ls <-檢視當前目錄下的檔案
ls / <-檢視根目錄下的檔案
ls ~ <-檢視家目錄下的檔案(等同於指令下ls /home)
ls .. <-檢視上層目錄中的檔案
ls ../.. <-檢視上兩層目錄中的檔案
ls -al <-檢視當前目錄中的檔案,可看到包含隱藏檔(-a)、長檔名檔案及軟連結的情況(-l)
ls -t <-先依照時間排序並檢視當前目錄下的檔案
- nl: 檢視檔案(附行數) [link]
Example:
nl file1.txt <-檢視file1.txt中的內容(附行數)
- ln: 建立連結 [link]
Example:
ln -s file1.txt link <-將link軟連結(Symbolic link)到file1.txt,檢視link有如同在檢視file1.txt
- pwd: 顯示目前路徑 [link]
pwd
- find: 尋找指令 [link]
find / -name robert <- 尋找根目錄下(/)有檔名為robert的檔案
- su: 切換身份 [link]
su -l robert <-切換身份到robert (ps. 指令打完須輸入robert身分的登入密碼)
- sudo: 使用root身分執行指令 [link]
sudo apt-get install openssh-server <-切換身份帳號到root執行安裝openssh-server (ps. 指令打完需要輸入root密碼)
sudo su <-切換身份帳號到root (ps. 指令打完需要輸入root密碼)
- cat: 觀察或複製多檔 [link]
cat file1.txt <-在cmd模式下看file1.txt的內容
cat -n file1.txt <-在cmd模式下看到有顯示行數的file1.txt內容
cat -A file1.txt <-在cmd模式下看file1.txt的內容,亦可看到句尾的斷行符號
cat file1.txt | more <-當檔案大於一頁,可以用此方式檢視file1.txt較為方便
cat file1.txt file2.txt > file3.txt <-將file1.txt與file2.txt合併到file3.txt,在file3.txt依序顯示file1.txt然後顯示file2.txt
- cp: 複製檔案或目錄(含內容) [link]
Example:
cp ../file1.txt . <-複製上一層目錄下的file1.txt到目前的目錄
cp -r ../folder1 . <-複製上一層目錄下的資料夾folder1(含內部檔案)到目前的目錄
cp -a file1.txt file2.txt <-複製一份檔案相同於file1.txt的檔案(含檔案屬性)到file2.txt
cp -a . folder1/ <-複製目前目錄下所有檔案(包含隱藏檔跟資料夾)到資料夾folder1
- mv: 移動檔案或重新命名 [link]
mv app1.c folder1 <-將單一app1.c檔案移動到folder1中
mv app1.c app2.c folder1 <-將app1.c與app2.c檔案移動到folder1中 (ps.資料夾要放最後一個參數)
mv file1.c file2.c <-將file1.c更名為file2.c
- rm: 移除指令 [link]
rm file1.c <-刪除file1.c的檔案
rm -i file1.c <-詢問是否刪除file1.c的檔案 (使用這個指令比較安全)
rm -r folder1 <-刪除folder1下的所有檔案 (危險,請配合-i指令一起使用)
rm -rf folder1 <-強制刪除folder1下的所有檔案 (使用-f後,會忽略-i的警告提示)
rm -rf .* * <-強制刪除folder1下包含隱藏檔的所有檔案 (超危險,使用前請三思)
- source: 讀入環境設定檔 [link]
source env_setup.sh <-讀入env_setup.sh的環境設定檔
source ~/.bashrc <-讀入預設載入的./bashrc的環境設定檔 (當.bashrc經過修改時可使用)
Example:
grep int app1.c <-螢幕列出app1.c檔案中有int字串的行數及內容
grep -n int app1.c <-螢幕列出app1.c檔案中有int字串的行數及內容(包含行數)
grep -r int * <-螢幕列出當目錄下(含子目錄)所有檔案中含有int字串的行數及內容
grep -I "is a girl" folder <-螢幕列出folder目錄下所有非binary檔中含有is a girl字串的行數及內容
grep "a girl" * --exclude=*.log <-螢幕列出當目錄下所有檔案(除了名為xxx.log外)中含有a girl字串的內容
- which: 指令位置 [link]
which ls <-螢幕秀出ls指令的執行binary的檔案位置
Subscribe to:
Posts (Atom)