2012年2月13日

Source命令

摘要: source命令用法:source FileName作用:在当前bash环境下读取并执行FileName中的命令。注:该命令通常用命令“.”来替代。如:source .bash_rc 与 . .bash_rc 是等效的。注意:source命令与shell scripts的区别是,source在当前bash环境下执行命令,而scripts是启动一个子shell来执行命令。这样如果把设置环境变量(或alias等等)的命令写进scripts中,就只会影响子shell,无法改变当前的BASH,所以通过文件(命令列)设置环境变量时,要用source 命令。source命令(从 C Shell 而来)是b 阅读全文

posted @ 2012-02-13 15:52 perlman 阅读(22682) 评论(0) 推荐(5) 编辑

Shell语句可以直接写在命令行上

摘要: 一般我们都是将Shell命令写在脚本里,其实可以直接写在terminal中执行,比如下面这个for循环。for i in `ls`; do echo "$i\n"; done== 阅读全文

posted @ 2012-02-13 11:16 perlman 阅读(4265) 评论(0) 推荐(0) 编辑

Perl使用chdir

摘要: 代码如下use strict;use warnings;# Print all files in a directorysub print_files { my $dir = 'd:/code'; opendir DIR, $dir or die $!; my @files = readdir DIR; chdir $dir; # Use chdir or -f will not work, since -f need absolutely path foreach my $file (@files) { if (-f $file) { ... 阅读全文

posted @ 2012-02-13 11:11 perlman 阅读(3973) 评论(0) 推荐(0) 编辑

导航