1.创建文件:touch file 如:touch temp.log则创建了一个temp.log文件。
2.删除文件:rm 如:rm temp.log。
3.打印文字echo "some text"
4.查看文件别表:ls
5.计算文件行数: wc –l file;计算文件中的单词数: wc -w file;计算文件中的字符数: wc -c file;
6. 重命名文件或移动文件 mv oldname newname ;
7.删除文件: rm file;
8.在文件内搜索字符串 grep 'pattern' file;
9.指定欲显示的文件内容范围,并将它们输出到标准输出设备:cut -b colnum file;
10.输出文件内容到标准输出设备(屏幕)上:cat file;
11.查看文件类型:file temp.log, 如输出结果为(temp.log: UTF-8 Unicode text, with very long lines)。
12.查找文件,如:find . -name temp.log;
13.打印文本文件开头几行:head file;打印文本文件末尾几行: tail file;
14.在file.txt中搜索包含有”hello”的行并计算其行数 grep "hello" file.txt | wc -l;
15.浏览整个文件 vi filename ,然后可以用“/关键字”的形式从该文件中地位该关键字的位置。
16.看文件的前n行(并且导入到某文件下) head -250000 temp.log > /app/java/tomcat6/logs/tem.log;
17.查看文件的 第n1至n2行的数据(并且导入到某文件下) sed -n '1,10p' temp.log> tem.log;
18.从文件中搜索某个关键字 grep 'processed' temp.log > tem.log;
19.打包某个文件 gzip temp.log。
20.远程登录到某台机器 telnet 10.50.98.174 。
21.从服务器上拿文件的步骤 1.ftp 10.50.98.183 ;2.进入指定目录:cd /smartpay/log 3.获取文件get systemjob.log 4推出by。
22.停止防火墙:service iptables stop ; 启动防火墙:service iptables start ;
23.复制文件夹到另一个文件夹 :cp -r /tools/tomcat/ ../opt;
24.重启命令:reboot ,关机命令:halt ;
25.解压文件:tar -zxvf xxx.tar;(zxvf:)