UNIX
UNIX bc的小数除法
这个东东整了我大半天的时间。。。
因为前面的代码算出一个TotalTime的结果是个科学计数法1.23456e+08这样的东东,在windows的MKS下只要简单的用
AverageTime=`expr $TotalTime / $total_num`
就ok了。
搬到UNIX服务器下跑就报expr expect a integer
开始是以为分子必须为整数,就搜出来一个方法,用bc控制分子的精度
AverageTime=`echo “scale=0;$TotalTime/$total_num”|bc’ //这个对于分子是小数点的情况还是好使的:)
这个方法在UNIX命令行直接跑能赋值,但是echo $AverageTime就会报Syntex Error in line1,
代入数字,一行行跑:
AverageTime=`echo “scale=2;$2.5/$2″|bc’
echo $AverageTime
能得出1
然后找Jason帮我调了调,到代人
AverageTime=`echo “scale=1.23456e+08;$2.5/$2″|bc’
同样报出Syntex Error in line1,
最后一顿狂搜,快下班的时候终于让我找到打印命令,开始用%d,说无法转换,想起来以前C的时候也用一样的格式符,就试了%.0f,搞定~
AverageTime=`expr $TotalTime / $total_num`
写shell script的基础篇zz
找了个写shell script的基础篇,zz一下:
Shell Programming
Abstract:
In this article we explain how to write little shell scripts and give many examples.
Why shell programming?
Even though there are various graphical interfaces available for Linux the shell still is a very neat tool. The shell is not just a collection of commands but a really good programming language.You can automate a lot [...]
How to put files from Windows to UNIX
open CMD window in Windows, type
ftp 111.111.111.111 //UNIX server name ,
or :
ftp -i 111.111.111.111 //will not prompt to ask y/n for each file; if you already typed ftp 111.111.111.111, you can also just type prompt to switch the on/off of the y/n asking
type UNIX username and password when asked
cd to the path you want to [...]
用mkdir 命令一次生成嵌套的多个目录
mkdir 命令
功能:创建一个目录(类似DOS下的md命令)。
语法:mkdir [选项] dirname
说明:该命令创建由 dirname 命名的目录。要求创建目录的用户在当前目录中(dirname 的父目录中)具有写权限,并且 dirname 不能是当前目录中已有的目录或文件名称。
命令中各选项的含义如下:
-m 对新建目录设置存取权限。也可以用chmod命令设置。 -p 可以是一个路径名称。此时若路径中的某些目录尚不存在,加上此选项后, 系统将自动建立好那些尚不存在的目录,即一次可以建立多个目录。
指令实例:
mkdir -p -m 700 ./inin/mail/ % 该命令的执行结果是在当前目录中创建嵌套的目录层次inin 和inin下的mail目录, 权限设置为只有文件主有读、写和执行权限。
———————————————————————摘自指令说明
热烈庆祝我在美国pass了试用期-FTP/UNIX script recording功能
今天查看工资条,一算,居然已经过了试用期12天了.不知不觉啊…其实算这个日子的唯一目的是以后可以去健身…
回归正题,在美国这段时间还是学了不少东西,涉及行业准则的东西不能说,就透露一些常用软件的小技巧吧:)
FTP:不知道其它的FTP有没有这个功能的,公司这款FTP有个record script的功能,选择后就开始recording,然后在命令栏的输入,或者鼠标点击产生的命令就可以被录下,选择stop recording,然后选择一个路径,保存成script文件,下次需要的时候就run script就可以了.因为我的工作需要打开一个比较复杂的路径,而本地也要打开一个特别目录,有了这个功能就特别方便.
UNIX:其实应该是WRQ Reflection才对.用它连接到服务器端的UNIX上.同样地,也是每次都要输入一大堆一样的命令,我就想是不是也有一个一样的recording功能呢?果然,在Marco里面有个recording…后面就不用多说了吧:)
using "cat" to concatenate files to another
I saw my leader used “cat”, but searching for many sites, there is only output to standard output file – screen.This is how to use it:cat fileA fileB fileX > fileAnother
fileAnother will include all the files before “>” in order


