文件解压缩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. PJISP 修改 消息头Fromto字段

    项目需求,需要修改sip信令消息头中Fromto字段,完成此功能需要修改sip库(PJSIP)源码,具体如下: PJSIP 消息头 Formto  字段默认的格式是sip:平台@平台IP地址,例如si ...

  2. springboot学习(二) 第一个springboot项目:Hello World!

    1.简介 可以像使用其他java标准库那样使用spriongboot,只需简单地在你的classpath下包含正确的 spring-boot-*.jar 文件.springboot不需要集成任何特殊的 ...

  3. 【CODEFORCES】 A. Initial Bet

    A. Initial Bet time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  4. atititi.soa  微服务 区别 联系 优缺点.doc

    atititi.soa  微服务 区别 联系 优缺点.doc 1. 应用微服务的动机,跟传统巨石应用的比较1 2. 面向服务架构(SOA)  esb2 3. 微服务架构(Microservices)2 ...

  5. [译]GLUT教程 - 重整子窗体

    Lighthouse3d.com >> GLUT Tutorial >> Subwindows >> Reshape Subwindows 重整函数的回调需要处理两 ...

  6. redis+node.js

    1.什么的cache 是一种更快的记忆存储数据集 存储空间有限 储存一部分重要数据 是一种相对的概念,只要比原本数据存储更快的介质就能作为cache 2.caching 策略 有限的存储空间,只能存储 ...

  7. Java并发专题 带返回结果的批量任务执行

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/27250059 一般情况下,我们使用Runnable作为基本的任务表示形式,但是R ...

  8. atom常用插件安装

    安装插件方法: File -Settings -Install 在搜索框里搜索你想要的插件,出来之后 点击install ,下图以 linter-selint 为例 ATOM常用插件推荐 simpli ...

  9. 从xhr说起

    原生xhr对象存在较多的兼容性,IE6及之前版本使用ActiveXObject对象来创建,IE7以后使用兼容版本的MSXML2.XMLHttp.MSXML2.XMLHttp3.0.MSXML2.XML ...

  10. [Sdoi2013]随机数生成器(BSGS)

    #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #inclu ...