shell文件相关指令
文件解压缩tar
请参考文档:http://blog.csdn.net/eroswang/article/details/5555415/
tar -zcvf ${standardpath}${filename}.tar.gz ${filename}
文件删除rm
rm -r /dir
rm file
rm -rf /dir
-r, -R, --recursive
remove directories and their contents recursively
-f, --force
ignore nonexistent files and arguments, never prompt
-i prompt before every removal
文件复制cp
cp /sourcefile /destinationfile
cp sources /directory
-R, -r, --recursive
copy directories recursively
-n, --no-clobber
do not overwrite an existing file (overrides a previous -i option)
-f, --force
if an existing destination file cannot be opened, remove it and try again (this option is ignored when the -n option is also
used)
文件移动,重命名mv
mv sourcefile destfile/path
mv sourcedir destdir
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
-f, --force
do not prompt before overwriting
-i, --interactive
prompt before overwrite
-n, --no-clobber
do not overwrite an existing file
改变工作目录cd
cd - 回到上一次的工作目录
cd
cd ~
cd /
创建目录mkdir
mkdir dirname
-p, --parents
no error if existing, make parent directories as needed
mkdir -P /path
创建文件touch
touch file
查看文件路径pwd
pwd
查看文件大小du
du -h
du -h /path
stat -c%s /home/hadoop/test.txt
查看目录下文件数量
ls -l | grep '^-' | wc -l
查看目录下子目录的数量
ls -l | grep '^d' | wc -l
查看文件详细信息ls
ls
ls -l / ll
ls -ash
-a, --all
do not ignore entries starting with .
-h, --human-readable
with -l and/or -s, print human readable sizes (e.g., 1K 234M 2G)
-s, --size
print the allocated size of each file, in blocks
-l use a long listing format
查找文件find,which
find [路径] [参数]
参数说明:
时间:
-atime n :在 n*24小时内被 access 即存取过的文件列出来!
-ctime n :在 n*24小时内被 changed 即改变、新增的文件或目录印出
-mtime n :在 n*24小时内被 modified 即修改过的文件印出
-newer file :比 file 还要新的文件就列出来! 使用名称: -gid n :寻找 群组 ID 为 n 的文件
-group name :寻找群组名称为 name的文件
-uid n :寻找拥有者 ID 为 n 的文件
-user name :寻找使用者名称为 name 的文件
-name file :寻找档名为 file 的文件名称(可以使用万用字符)
-type type :寻找档案属性为 type 的档案,type 包含了 b, c, d, p, l, s,这些与前一章的属性相同!例如 l 为 Link而 d 为路径之意! which ls(which也可以查找)
例如 [root@bestlinux ~]# find / -nametesting //查找名为 testing 的文件
[root@bestlinux ~]# find / -name'test*' //查找以test开头的文件
[root@bestlinux ~]# find . -ctime1 //查找当前目录下一天内新增的文件
[root@bestlinux ~]# find /home -usertest //查找 /home下拥有者为 test 的文件
查看文件内容cat,head,tail
cat /etc/services
head -n /etc/services(查看文件前n行的内容)
tail -n /etc/services(查看文件后n行内容)
more /etc/services (文件内容会一屏一屏的显示出来,你只需用空格键就可以下翻了)
cat /etc/services | more(cat显示出来的内容重新输出给 more 命令就可以达到想要效果)
查看文件内容的行数
wc -l /etc/services
以上内容参考了:http://www.cnblogs.com/lanse-yan/archive/2012/11/29/2794300.html
shell文件相关指令的更多相关文章
- llinux文件相关指令
一---导读 首先我们来看这样一个小案例,假设张三要出差,按照 这样的路线进行 北京->上海,之后回到北京.再按照北京->天津->石家庄这样的路线进行出差(北京是根据地).假设现在张 ...
- linux查看文件相关指令
以下内容整理自以下两篇文章: http://www.cnblogs.com/xilifeng/archive/2012/10/13/2722596.html Linux 查看文件内容的命令 http: ...
- adb相关指令 笔记
adb相关指令 笔记 1.adb devices 查看物理测试设备或模拟器的相关信息,有三个状态: (1)device 设备已连接到adb服务器上,但该状态并不代表设备已启动完毕可以进行操作: ( ...
- ADB相关指令实例详解
1.获取物理设备相关信息: adb devices 2.apk安装 2.1 新的应用(该应用未安装) adb -s 设备序列号 install apk路径 2.2 应用已安装,重安装覆盖 adb -s ...
- [ARM] Cortex-M Startup.s启动文件相关代码解释
1. 定义一个段名为CSTACK, 这里: NOROOT表示如何定义的段没有被关联,那么同意会被优化掉,如果不想被优化掉就使用ROOT. 后面的括号里数字表示如下: (1):这个段是2的1次方即2字节 ...
- Linux Shell系列教程之(十七) Shell文件包含
本文是Linux Shell系列教程的第(十七)篇,更多Linux Shell教程请看:Linux Shell系列教程 通过文件包含,可以引用其他文件的内容,也可以将复杂内容分开,使程序结构更加清晰. ...
- Linux相关指令
Linux相关指令 1.find文件搜索功能 find [目录列表] [匹配参数] [匹配标准] -name :按文件名称进行搜索 -group :按文件所属组进行搜索 -user :按文件拥有者进行 ...
- 3_Linux_文件搜索指令
.3文件搜索命令 1)which 查找一个命令所在的路径 whereis 提供命令的帮助文件的信息 whatis 显示命令的概要信息whatis ls which提供命令的别名信息 2)find,基本 ...
- Linux指令--性能监控和优化命令相关指令
原文出处:http://www.cnblogs.com/peida/archive/2012/12/05/2803591.html.感谢作者无私分享 性能监控和优化命令相关指令有:top,free,v ...
随机推荐
- .net core 2.0小白笔记(一):开发运行环境搭建
小白一枚,有任何不妥之处敬请指教 这里不讨论什么设计模式,什么架构,什么什么,就是入门,简单的入门,虽然能跨平台,但是这里还是在win的环境下进行,不扯的那么远 其实官网文档写的挺不错的了,就是偶尔有 ...
- Iocomp控件教程之LinearGauge--线性刻度尺控件
线性刻度尺-线性刻度尺控件(LinearGauge)是一个具有线性表达式刻度的图像控件.支持多达5种颜色断面和4种指示器样式,相同功能,查看线性对数刻度尺(Linear Log Gauge)控件内容 ...
- Atitit.远程接口 监控与木马 常用的api 标准化v2 q216
Atitit.远程接口 监控与木马 常用的api 标准化v2 q216 1. 木马与远程接口 监控的常用的api2 1.1. 文件复制2 1.2. 屏幕定时截图2 1.3. 邮件发送2 1.4. ...
- MySQL八:视图、触发器、事物、存储过程、函数
阅读目录 一 视图 二 触发器 三 事务 四 储存过程 五 函数 六 流程控制 一 视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用[名 ...
- oracle浅析导致数据库性能问题的常见原因
㈠ 不合理的大表全表扫描 详见:点击打开链接 v$session_longops视图记录了超过6秒的所有SQL语句 这其中绝大部是全表扫描的语句! ㈡ 语句共享性不好 常出没在OLTP, ...
- Eclipse中Copy Qualified Name复制类全名解决办法
Eclipse中用Copy Qualified Name复制类全名时总是这样的/struts1/src/me/edu/HelloAction.java很不方便可以这样解决下载下边插件解压到Eclips ...
- Idea中优化Markdown Support显示效果
转自:https://www.jianshu.com/p/d093c42a8c29 因为工作中为提高工作效率,我一般习惯于直接在`idea`中使用`markdow support`插件来进行相关文档的 ...
- Matlab典型论坛
Matlab典型论坛 http://www.ilovematlab.cn/forum.php?tid=271705&goto=lastpost
- android webview 加载本地html 实现 与 java 之间的相互响应
1.布局 <?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:androi ...
- wordpress 获取分类ID,分类标题,分类描述,分类链接url函数
get_cat_ID() 根据分类名称获取分类ID ///// get_cat_name() 根据分类ID获取分类名称 用法:<?phpget_cat_ID( $cat_name ...