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

Linux Commands intro1

时间:2015-08-15 07:55:15      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:

$((expression))

echo $(2+2) :wrong

echo $((2+2))  : right

echo Front-{A,B,C}-Back

Front-A-Back Front-B-Back Front-C-Back

echo start{1..5}end
start1end start2end start3end start4end start5end

echo start{A..Z}end

$(cmd)

命令替换 一个命令的输出作为另一个命令的参数

uses back quotesinstead of the dollar sign and parentheses:

ls -l `which cp` 等价于

ls –l $(which cp)

It is also common to use escaping toeliminate the special meaning of a
character in a filename. For example, it is possible to use characters in filenames that normally have special meaning to the shell. These would include
$, !, &,  (a space), and others. To include a special character in a filename,
you can use \ to escape.

 

file filename #determine the file type
ls -lt #show files sort by time
less filename #allow you scroll down and up to see the file content
ln -s target linkname #used to create a soft link for one file or folder

wc—Print newline, word, and byte counts for each file.

tee—Read from standard input and write to standard output and files.

执行一个shell的时候,可以在屏幕上打出日志,同时又保存在文件中。

sh mysh.sh 2>&1 | tee mysh.log

sh mysh.sh >mylog.log 2>&1

 

1 : standard output

2: standard error output

if you want to throw the error away, you can output to

sh mysh.sh 2> /dev/null

> output content to a new file

>> append data to file

< read data from file

 

技术分享

 

1.过滤今天产生的文件?(日志文件)

find / –type f –mtime –1

find –name ‘pattern’ –exec rm {} \;

find / –name test | xargs rm –rf;

 

2.根据年月快速创建一些文件夹?

mkdir {2009..2011}-0{1..9} {2009..2011}-{10..12}
[me@linuxbox Pics]$ ls
2009-01 2009-07 2010-01 2010-07 2011-01 2011-07
2009-02 2009-08 2010-02 2010-08 2011-02 2011-08
2009-03 2009-09 2010-03 2010-09 2011-03 2011-09
2009-04 2009-10 2010-04 2010-10 2011-04 2011-10
2009-05 2009-11 2010-05 2010-11 2011-05 2011-11
2009-06 2009-12 2010-06 2010-12 2011-06 2011-12

jobs—List active jobs.

bg—Place a job in the background.
fg—Place a job in the foreground.

Linux Commands intro1

标签:

原文地址:http://www.cnblogs.com/huaxiaoyao/p/4731647.html

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