---
title: "Linux常用命令2"
author: "forrest420"
date: "2011-09-30T15:12:51Z"
tags: ["Linux"]
categories: ["操作系统"]
slug: "linux-2"
draft: false
lastmod: "2011-12-31T11:35:06Z"
id: 1183987
url: "https://forrest420.iteye.com/blog/1183987"
---

Linux系统内核文件Cache管理机制简介
http://blog.chinaunix.net/space.php?uid=432947&do=blog&cuid=327801

显示昨天的日期：减去24小时，并按指定格式输出%Y%m%d
DAY=`date --utc -d "-24 hour" +"%Y%m%d"`
echo $DAY
输出结果为:20110927

year=`echo $DAY| cut -c1-4`
echo $year
2011
将m1log.log和m2log.log都存入mb.log
cat /a/m1log.log > /b/mb.log
cat /a/m2log.log >> /b/mb.log

Linux find commmand
http://content.hccfl.edu/pollock/unix/findcmd.htm
find / -name foo 2>/dev/null

Conditions in bash scripting, (if statements)"[]"和"[[]]"的区别
http://www.linuxtutorialblog.com/post/tutorial-conditions-in-bash-scripting-if-statements

Tar打包、压缩与解压缩到指定目录的方法
 
tar在linux上是常用的打包、压缩、加压缩工具，他的参数很多，折里仅仅列举常用的压缩与解压缩参数
 
参数：
-c ：create 建立压缩档案的参数；
-x ： 解压缩压缩档案的参数；
-z ： 是否需要用gzip压缩；
-v： 压缩的过程中显示档案；
-f： 置顶文档名，在f后面立即接文件名，不能再加参数
 
举例： 一，将整个/home/www/images 目录下的文件全部打包为 /home/www/images.tar
[root@xoaocom ~]# tar -cvf /home/www/images.tar /home/www/images ← 仅打包，不压缩
[root@xoaocom ~]# tar -zcvf /home/www/images.tar.gz /home/www/images ← 打包后，以gzip压缩
 
在参数f后面的压缩文件名是自己取的，习惯上用tar来做，如果加z参数，则以tar.gz 或tgz来代表gzip压缩过的tar file文件
 
举例： 二，将 /home/www/images.tar.gz 解压到/home/www下面
[root@xoaocom ~]# cd /home/www
[root@xoaocom ~]# tar -zxvf /home/images.tar.gz
 
解压到指定的目录
[root@xoaocom ~]# tar -zxvf /home/images.tar.gz -C /specific dir
 
解包到指定的目录
tar xvf filename.tar -C /specific dir


MAILTO="abc@163.com"
if [[ `cat /a/error.log | wc -l` != 0 ]] ; then
	mail -s "error out" $MAILTO < /a/error.log;
fi

Linux for Loop
http://www.freeos.com/guides/lsst/ch03sec06.html

Linux cut command
http://lowfatlinux.com/linux-columns-cut.html
