Linux操作系统学习记录二

      在Linux中感受到shell脚本的强悍,于是便有此文,linux 中有crontab(监控程序)定时运行一些任务
在Linux中删除一个东西 ,我一般都是用mv移到指定的文件夹中,然后用shell脚本定时清空这个文件夹,下面是一个简单的定时任务,执行shell脚本的例子,清空指定文件夹中的东西 ,并把删除的信息到发送到自己的邮箱里:
#shell文件clean放在桌面上
#!/bin/bash
if test -e /data ; then
    size=`du -s /data |  awk '{print $1}'` #data的文件大小
    if [ $size -gt 1024 ] ;then#data文件夹大于1M才执行删除
        str='ls /data/*'
        echo "以下文件被删除!" >/temp.txt
        echo $str >>/temp.txt
        mutt -s "鸟ubuntu的信息" ***@gmail.com </temp.txt
        rm -rif /data/*
        echo '数据删除完毕!';
        exit;
    fi
fi
#先安装发送邮件的工具 sudo apt-get install  mutt
#然后再用crontab -e 来制定任务于下
#30 10 * * * /home/td/桌面/clean
#每天10点30执行一次
#完成以上就OK了
shell 操作符

返回真(退出状态0)的条件
int1 -eq int2 int1等于int2
int1 -ge int2 int1大于或等于int2
int1 -gt int2 int1大于int2
int1 -le int2 int1小于或等于int2
int1 -lt int2 int1小于int2
int1 -ne int2 int1不等于于int2
判断文件
-r file     用户可读为真
-w file     用户可写为真
-x file     用户可执行为真
-f file     文件为正规文件为真
-d file     文件为目录为真
-c file     文件为字符特殊文件为真
-b file     文件为块特殊文件为真
-s file     文件大小非0时为真
-t file     当文件描述符(默认为1)指定的设备为终端时为真
以下是vim  vimic 配置文件,显示漂亮vim编辑器
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below.  If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed.  It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.

" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
syntax on

" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark
set background=dark

" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
"  au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
"    \| exe "normal g'\"" | endif
"endif

" Uncomment the following to have Vim load indentation rules according to the
" detected filetype. Per default Debian Vim only load filetype specific
" plugins.
if has("autocmd")
  filetype plugin on
  filetype indent on
endif

" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
set showcmd		" Show (partial) command in status line.
set showmatch		" Show matching brackets.
set ignorecase		" Do case insensitive matching
"set smartcase		" Do smart case matching
set incsearch		" Incremental search
"set autowrite		" Automatically save before commands like :next and :make
"set hidden             " Hide buffers when they are abandoned
set mouse=a		" Enable mouse usage (all modes) in terminals

" Source a global configuration file if available
" XXX Deprecated, please move your changes here in /etc/vim/vimrc
if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif

"###########################################################################

" install
" ctags,taglist,supertab,
" runscript 运行Python脚本
" csupport C语言相关支持
" TipOfTheDay 每天提示
" ColorSamplerPack 上百种颜色主题
" cppomnicomplete C++的对象成员补全

" vim python
" http://www.petersblog.org/node/752

set nocompatible
set number
set nobackup
map <F12> :! python % <CR>
map <F11> :! python -i % <CR>
map <F8> :! rst2html.py % %.html <CR>
colo desert
" 代码折叠相关
map <F3> zR
map <F2> zM
" 显示当前目录文件列表
map <F4> :e .<CR>
set cursorline

if has("autocmd")
    autocmd FileType python setlocal et | setlocal sta | setlocal sw=4
    autocmd FileType c setlocal et | setlocal sta | setlocal sw=4
    autocmd FileType h setlocal et | setlocal sta | setlocal sw=4
endif

" 编码字符集相关
"set guifont=Consolas:h9
set hlsearch
set fileencodings=ucs-bom,UTF-8,GBK,BIG5,latin1
set fileencoding=UTF-8
set fileformat=unix
set ambiwidth=double

set shiftwidth=4
set tabstop=4
set softtabstop=4
set expandtab
"set backspace=indent,eol,start
"set sta
set smarttab
set list "显示透明字符
"set lcs=eol:&,tab:<+ "设置显示tab为<+++或<++++++方式,以区别缩进
set lcs=tab:<+

" 设置不让vim响铃而是闪屏
"set vb t_vb=
"set novisualbell "貌似没有起作用
set noerrorbells
set visualbell

" Taglist 相关
let Tlist_File_Fold_Auto_Close=1
let Tlist_Show_Menu=1
"let Tlist_Use_Right_Window=1
"let Tlist_Auto_Open=1
"let Tlist_Exit_OnlyWindow=1
"let Tlist_Use_SingleClick=1
"let Tlist_Compart_Format=1
"let Tlist_Enable_Fold_Column=0
set updatetime=1000
"let g:ctags_statusline=1

" 代码折叠
"set foldlevel=0
"set foldenable
set foldmarker={,}
set foldmethod=marker
set foldlevel=100 "不去自动打开折叠
set foldopen-=search "搜索时不打开折叠
set foldopen-=undo "undo时不打开折叠
"set foldmethod=indent

if has("gui_running")
    set lines=25 "在768分辨率下显示竖排两个gvim
    set columns=80 "在1024分辨率正好两个并列的gvim
endif
"let mapleader="," "修改leader的快捷键?原来用\  ?
set smartcase "智能搜索,在搜索中如果全小写则不区分大小写,如有大写则区分
"set backspace=2 "退格键可以删除任何东西
set report=0
set lazyredraw "延迟重绘

set guioptions-=m "不显示菜单
set guioptions-=T "不显示工具栏
"set updatecount=0 "不使用交换文件
"set noswapfile "不使用交换文件?
"map <silent> <C-F2>: if &guioptions=~# 'T' <Bar>
"    \set guioptions-=T <Bar>
"    \set guioptions-=m <Bar>
"\else <Bar>
"    \set guioptions+=T <Bar>
"    \set guioptions+=m <Bar>
"\endif <CR>

"autocmd BufNewFile *.py 0r ~/.vim/templates/simple.py
"autocmd FileType python set complete+=k~/.vim/tools/pydiction
set ruler "总是在最底部显示当前光标位置

" unknown
set wmnu
set cst
set csto=1
set backspace=2
set wildmenu
set magic
set uc=0
autocmd FileType python set complete+=k~/.vim/tools/pydiction

猜你喜欢

转载自dreamshow.iteye.com/blog/835709