文件解压缩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文件相关指令的更多相关文章

  1. llinux文件相关指令

    一---导读 首先我们来看这样一个小案例,假设张三要出差,按照 这样的路线进行 北京->上海,之后回到北京.再按照北京->天津->石家庄这样的路线进行出差(北京是根据地).假设现在张 ...

  2. linux查看文件相关指令

    以下内容整理自以下两篇文章: http://www.cnblogs.com/xilifeng/archive/2012/10/13/2722596.html Linux 查看文件内容的命令 http: ...

  3. adb相关指令 笔记

      adb相关指令 笔记 1.adb devices 查看物理测试设备或模拟器的相关信息,有三个状态: (1)device 设备已连接到adb服务器上,但该状态并不代表设备已启动完毕可以进行操作: ( ...

  4. ADB相关指令实例详解

    1.获取物理设备相关信息: adb devices 2.apk安装 2.1 新的应用(该应用未安装) adb -s 设备序列号 install apk路径 2.2 应用已安装,重安装覆盖 adb -s ...

  5. [ARM] Cortex-M Startup.s启动文件相关代码解释

    1. 定义一个段名为CSTACK, 这里: NOROOT表示如何定义的段没有被关联,那么同意会被优化掉,如果不想被优化掉就使用ROOT. 后面的括号里数字表示如下: (1):这个段是2的1次方即2字节 ...

  6. Linux Shell系列教程之(十七) Shell文件包含

    本文是Linux Shell系列教程的第(十七)篇,更多Linux Shell教程请看:Linux Shell系列教程 通过文件包含,可以引用其他文件的内容,也可以将复杂内容分开,使程序结构更加清晰. ...

  7. Linux相关指令

    Linux相关指令 1.find文件搜索功能 find [目录列表] [匹配参数] [匹配标准] -name :按文件名称进行搜索 -group :按文件所属组进行搜索 -user :按文件拥有者进行 ...

  8. 3_Linux_文件搜索指令

    .3文件搜索命令 1)which 查找一个命令所在的路径 whereis 提供命令的帮助文件的信息 whatis 显示命令的概要信息whatis ls which提供命令的别名信息 2)find,基本 ...

  9. Linux指令--性能监控和优化命令相关指令

    原文出处:http://www.cnblogs.com/peida/archive/2012/12/05/2803591.html.感谢作者无私分享 性能监控和优化命令相关指令有:top,free,v ...

随机推荐

  1. Jenkins与Docker相关的Plugin使用

    原文地址:http://blog.csdn.net/ztsinghua/article/details/52128140 Jenkins与Docker相关的Plugin 在Jenkins Plugin ...

  2. CentOS7网络桥接模式下配置-经典完备

    原文地址:http://blog.csdn.net/youzhouliu/article/details/51175364 首先要将Vmware设置为桥接模式: 并选择宿主机连接的网路进行桥接: Ce ...

  3. python判断值是否为空

    代码中经常会有变量是否为None的判断,有三种主要的写法: 第一种是`if x is None`: 第二种是 `if not x:`: 第三种是`if not x is None`(这句这样理解更清晰 ...

  4. mysql中的for update

    Select…For Update语句的语法与select语句相同,只是在select语句的后面加FOR UPDATE [NOWAIT]子句. 该语句用来锁定特定的行(如果有where子句,就是满足w ...

  5. asp.net web.config配置节说明

    web.config 文件查找规则:      (1)如果在当前页面所在目录下存在web.config文件,查看是否存在所要查找的结点名称,如果存在返回结果并停止查找.      (2)如果当前页面所 ...

  6. 【JMeter4.0学习(十一)】之JMeter对(Mysql、Oracle)数据库性能测试脚本开发

    一.MySQL数据库链接: 注:下面所产生的问题一律参考详见:<[JMeter4.0]之遇到的问题总结(持续更新)>(包括Mysql.Orcale) 准备:引包,包路径一定要放对位置,参考 ...

  7. chef简介

    Chef 的简单介绍 Chef 主要分为三个部分 Chef Server.Workstation 以及 Chef Client.用户在 Workstation 上编写 Cookbook.然后,通过 k ...

  8. github 答题

    头脑王者 / 百万英雄 / 冲顶大会 / 芝士超人 自动答题:https://github.com/cxs1994/python_answer 头脑王者:https://github.com/sear ...

  9. Lumen开发:添加手机验证,中文验证与Validator验证的“半个”生命周期

    版权声明:本文为博主原创文章,未经博主允许不得转载. 添加手机验证方法可直接看这里:https://www.cnblogs.com/cxscode/p/9609828.html 今天来讲一下,Lume ...

  10. memcache 的使用

    基础知识 memcached 是一个开源项目,旨在利用多个服务器内的多余 RAM 来充当一个可存放经常被访问信息的内存缓存.这里的关键是使用了术语缓存:memcached 为加载自他处的信息提供的是内 ...