文件解压缩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. CentOS7网络桥接模式下配置-经典完备

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

  2. spark入门(helloworld插件)

    1 http://www.cnblogs.com/openfire/archive/2013/04/26/3044722.html 2 在bulid文件夹下,(注意为主目录不是插件下的bulid.xm ...

  3. LeetCode LinkList 23. Merge k Sorted Lists

    这两天一直也没有顾上记录一下自己做过的题目,回头看看,感觉忘的好快,今天做了一个hard,刚开始觉得挺难得,想了两种方法,一种是每次都从k个list中选取最小的一个,为空的直接跳过,再就是每次合并其中 ...

  4. matlab 常用函数汇总

    1. 特殊变量与常数 主题词 意义 主题词 意义 ans 计算结果的变量名 computer 确定运行的计算机 eps 浮点相对精度 Inf 无穷大 I 虚数单位 inputname 输入参数名 Na ...

  5. HTML5 2D平台游戏开发#7Camera

    在庞大的游戏世界中,玩家不能一览地图全貌,而是只能看到其中一部分,并一步步探索,这时就要用到一种技术来显示局部的地图,游戏术语称为摄像机(Camera).下面两张图中的白色矩形框表示了Camera的作 ...

  6. spark-submit 提交任务

    将工程打成jar 放入到linux中 切换到[root@node4 Desktop]# cd /usr/local/development/spark-2.0-hadoop2.6/bin/ 输入命令 ...

  7. 安装wamp后 异常Exception Exception in module wampmanager.exe at 000F15A0

    系统环境:Windows 2008 R2 64bit 安装环境:wampserver2.4-x64 按照正常windows安装程序,完成WAMP Server程序安装,安装完成启动WAMP Serve ...

  8. Spring在注入bean异常时的替换

    情形:需要把数据库1的连接池A注入到DAO中,但是如果数据库A的连接池实例化失败了整个项目也启动不了,这个时候希望用数据库2的连接池来替换. 这里没有想到什么好的解决方法,只是想到了工厂方法提供Bea ...

  9. Java 获取指定日期的方法汇总

    import java.text.DateFormat; import java.text.ParsePosition; import java.text.SimpleDateFormat; impo ...

  10. 从头认识java-17.5 堵塞队列(以生产者消费者模式为例)

    这一章节我们来讨论一下堵塞队列.我们以下将通过生产者消费者模式来介绍堵塞队列. 1.什么是堵塞队列?(摘自于并发编程网对http://tutorials.jenkov.com/java-concurr ...