码迷,mamicode.com
首页 > 系统相关 > 详细

Linux常用命令汇总

时间:2014-09-22 19:14:53      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   使用   java   ar   strong   

1、获取文件全路径
每次拼凑路径比较麻烦,希望一个命令能给出包含机器名的完整路径:
$ ls | sed "s:^:`pwd`/:" | sed "s/^/$HOSTNAME:/g"

[root@test1 test]# ls | sed "s:^:`pwd`/:" | sed "s/^/$HOSTNAME:/g"
test1:/root/test/t_t_20090301032655ttxt
test1:/root/test/t_t_20090301032655.txt

2、grep高亮显示匹配的关键词

ls|
bubuko.com,布布扣

3、Java程序调用脚本

#!/bin/bash
#by system
#date:20120709
#for java
classes=/home/httpd/search.example.com/WEB-INF/classes
servlet="$classes":/usr/local/tomcat/lib/servlet-api.jar
jardir=/home/httpd/search.example.com/WEB-INF/lib
JPATH="$servlet"
for j in `ls /home/httpd/search.example.com/WEB-INF/lib/*.jar`
do
# echo $j
JPATH="$JPATH":"$j"
# echo $JPATH
done
/usr/local/jdk1.6.0_30/bin/java -classpath $JPATH com.cnfol.search.IndexCreator.IndexCreato

  

4、tar
(1)--exclude

# tar -czvf test.tar.gz . --exclude cpTest.sh --exclude /root/test/test222222cp2222.txt
./
./test222222cp2222.txt
./batch_almfilter_20090301032655.txt
./test.tar.gz
./batch_almfilter_20090301032655ttxt

如有目录xxx, 下面多个文件并有目录tt和ppp,如只想打包文件而不想打包两目录,应用使用如下命令:
tar -czvf mm.tgz xxx/ --exclude xxx/tt --exclude xxx/ppp
注意:exclude后面子目录不要跟斜杠"/",否则exclude无效.

 

Linux常用命令汇总

标签:style   blog   http   color   os   使用   java   ar   strong   

原文地址:http://www.cnblogs.com/softidea/p/3986265.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!