0 cd 命令:

是最常用的的命令,其中,下面两个是最经常用的的几个参数。

1.1 #cd ~ 到本人工作目录的根目录

1.2 #cd - 到上一次所在的目录

1 grep 实例:

grep -参数 "匹配目的内容" 要匹配文件目标

举例

1.1 grep 查找某个文件夹下所有文件中的字符

用grep 命令查找一个文件夹下,所有的编译选项含-diretfb的文件,比如makefile

grep -r "-diretfb" ./

fgrep -r directfb ./ > yourmake.log

1.2 grep 查找某个文件内的字符

从文件内容查找匹配指定字符串的行:
$ grep "被查找的字符串" 文件名
从文件内容查找与正则表达式匹配的行:
$ grep –e “正则表达式” 文件名
查找时不区分大小写:
$ grep –i "被查找的字符串" 文件名
查找匹配的行数:
$ grep -c "被查找的字符串" 文件名
从文件内容查找不匹配指定字符串的行:
$ grep –v "被查找的字符串" 文件名

1.3 grep 和 find 结合使用,可以查找特定文件中含特定字符的文件并打印报错,这个功能比windows的强大的多

1.3.1 从根目录开始查找所有的文件中含有的某个字符串的文件 和find连用
从根目录开始查找所有扩展名为.xml的文本文件,找到的结果用xargs分解,然后从找到的文件中找出包含”username”的行
find / -type f -name "*.xml" | xargs grep "username"

结果往往很大,直接存档到文件再查看 > find_usename_log.txt 加到上面的命令后面

the following is the often used comand that used to search a project C files for a demand key words "play_open",and all the result include the error result would list in the txt file

find ./ -type f -name "*.c" | xargs grep "player_open" > find_player_open.txt 2>&1

find ./ -type f -name "*.*" | xargs grep "GOODMAN" > find_GOODMAN.txt 2>&1

为了便于理解,有关于xargs的描述: 如下:http://blog.csdn.net/zhangfn2011/article/details/6776925

1.3.2 查找项目中所有的编译后产生的config.log中各种Lib的编译工具gcc的版本是否一致:

find . -type f -name "*config.log" | xargs grep "gcc version"


3 擦写

一个文件,往往用于嵌入式中擦写flash设备

1. 产生一个全0xFF, 0xA5, 0xAA 的文件

tr '\000' '\377' < /dev/zero| dd f=file_0xFF.bin  bs=2k count=1 // 用到的比较多
tr '\000' '\245' < /dev/zero| dd f=file_0xA5.bin  bs=2k count=1
tr '\000' '\252' < /dev/zero| dd f=file_0xAA.bin  bs=2k count=1


3. Find 的组合操作举例

3.0 find ./ -type d -name '.svn*' | xargs rm  -rf
找到并删除 名字里面带 svn的folder...

命令对找到文件执行多个操作

find -name abc.txt  -exec touch {} \; -exec ls -l {} \; -exec cat {} \;

3.1 Find 命令找两种以上的文件

find .  \( -name "makefile" -o  -name "*.patch" -o  -name "*.txt" \)

3.2 find 和grep连用

hsy75:查找根目录或者当前文件夹下,文件后缀为filetype的文件名为filename的文件

find / | grep "filename\.filetype$"

举例:

要查找根目录下directfb.a的动态库

find / | grep "directfb\.a$"

得到结果:

apps/directfb/DirectFB-1.4.3/src/.libs/libdirectfb.a
apps/usr/lib/libdirectfb.a
/opt/lib/libdirectfb.a
/debug/lib/libdirectfb.a
/usr/lib/libdirectfb.a

3.3 一些从man page里面的复杂的find 的例子,介绍的非常详细

------------------------------------------------

#从根目录查找当天变化的文件

find $HOME -mtime 0

Search for files in your home directory which have been modified in the last twenty-four hours.  This command works this way because the time since
       each  file  was last modified is divided by 24 hours and any remainder is discarded.  That means that to match -mtime 0, a file will have to have a
       modification in the past which is less than 24 hours ago.

------------------------------------------------

cd /source-dir
       find . -name .snapshot -prune -o \( \! -name *~ -print0 \)|
       cpio -pmd0 /dest-dir

This  command  copies  the  contents  of /source-dir to /dest-dir, but omits files and directories named .snapshot (and anything in them).  It also
       omits files or directories whose name ends in ~, but not their contents.  The construct -prune -o \( ... -print0 \) is quite common.  The idea here
       is  that  the  expression before -prune matches things which are to be pruned.  However, the -prune action itself returns true, so the following -o
       ensures that the right hand side is evaluated only for those directories which didn't get pruned (the contents of the pruned  directories  are  not
       even  visited,  so  their contents are irrelevant).  The expression on the right hand side of the -o is in parentheses only for clarity.  It empha‐
       sises that the -print0 action takes place only for things that didn't have -prune applied to them.  Because the  default  `and'  condition  between
       tests binds more tightly than -o, this is the default anyway, but the parentheses help to show what is going on.

----------------------------------------------------

find repo/ -exec test -d {}/.svn -o -d {}/.git -o -d {}/CVS ; \
       -print -prune

Given the following directory of projects and their associated SCM administrative directories, perform. an efficient search for the projects' roots:

repo/project1/CVS
       repo/gnu/project2/.svn
       repo/gnu/project3/.svn
       repo/gnu/project3/src/.svn
       repo/project4/.git

In  this example, -prune prevents unnecessary descent into directories that have already been discovered (for example we do not search project3/src
       because we already found project3/.svn), but ensures sibling directories (project2 and project3) are found.


4. echo 代替键盘输入

echo -e “\n\n\n”  三个回车

从   AC_MGMT 中摘录的echo 代替键盘输入的 片段

18 useradd $AC_ID -g $GRP_ID -m && \
 19 echo -e "$AC_ID\n$AC_ID\n"|passwd  $AC_ID && \
 20 echo "Create Successfully."
 21 echo "Enabling Samba For $AC_ID..."
 22 echo -e "$AC_ID\n$AC_ID\n$AC_ID\n"|smbpasswd -s -a $AC_ID && \
 23 smbpasswd -e $AC_ID
 24 echo "Samba Account for $AC_ID Done."

hsy75案:echo -e 是shell command 处理经常用到的方法,用来自动输入用户的输入,上文,根据用户输入变量AC_ID自动创立了一个samba的用户

当然,变量AC_ID应该要用户自己输入的


5. 利用变量内嵌执行

找到所有ko并copy

cp $(find *.ko) to_dir


6. 暂停运行程序和恢复

CTRL-Z    暂停运行程序
jobs      查看当前任务列表
fg num    前台运行任务列表中 num 任务
bg num    后台运行任务列表中 num 任务


7. 无终端运行程序

a.  nohup  <command>
b.  利用括号() 使进程成为 init(pid=1) 的子进程
    (ping 192.168.0.1 &)
    可用 ps -ef  看到 进程PID 和父进程PPID


8:tar 命令

将tar 和find 结合,选定目录下指定的文件类型进行打包解压:


tar命令用语对文件进行归档以及恢复归档文件,
"tar xzvf"命令用于释放<恢复>".tar.gz"格式压缩的归档文件;
"tar xvf"命令用于释放<恢复>".tar"格式压缩的归档文件;
"tar xjvf"命令用于释放<恢复>".tar.b2z"格式压缩的归档文件;

tar xzvf +软件包名称 |find . -type f -name "*.cpp "


打包 : tar cvf + 打包后文件名 + 需打包文件夹名
tar -cvf target_file.tar target_folder/
或者有选择的压缩

tar cvjf file-cpp.tar.bz2 | find . -type f -name "*.cpp"
或者
find . -type f -name "*.cpp" |  xargs  tar zcvpf backup.tar.gz


9 patch

制作补丁
打补丁

给文件夹打补丁:

1 进入你需要补丁的文件夹:

wine@ubuntu:~/directfb_4.1/DirectFB-1.4.3$

2 执行补丁程序:

patch -p1 < ../DirectFB-1.4.3.patch


10 chmod

要求就是:
1、将当前目录中的所有“子目录”的权限设置为755;
2、将当前目录中的所有“文件”的权限设置为644。
解决方法:
chmod 644 -R *
chmod 755 `find -type d`
也可以用:
用find彻底些
find /path -type f -exec chmod 644 {} /;
find /path -type d -exec chmod 755 {} /;

将*.jpg文件名中的09v9改为0919
Zianed@ubuntu:~/public_web_sSmO9OUVY1/files/image$ rename ’s/09v9/0919/’ *.jpg

ref:


http://ss64.com/bash/tar.html

http://topic.csdn.net/u/20071112/18/5630fa3e-d0cf-43ed-bc88-fb048ef1e482.html
3
http://zh.wikipedia.org/wiki/Xargs
ref:

http://www.eetop.cn/blog/?uid-51552-action-viewspace-itemid-26822


ref:

http://www.linuxso.com/command/


2012-12-21 add a find example for list vary result in search a key words in a project files

2013-04-10 add more good command

2014-12-24 porting from eetop

By Franklin :

[bz][LINUX command 002] 嵌入式常用的命令相关推荐

  1. Linux的使用以及常用的命令

    Linux的使用以及常用的命令 概述 Linux的历史 操作系统,英语Operating System简称为OS.说道操作系统就需要先讲一讲Unix,UNIX操作系统,是一个强大的多用户.多任务操作系 ...

  2. linux在A目录下创建B文件,Linux课程---5、常用文件命令和目录命令(创建文件命令)...

    Linux课程---5.常用文件命令和目录命令(创建文件命令) 一.总结 一句话总结: touch file1 1.管道符|有什么用? 将前一个命令的结果作为后一个命令的输入:比如查看文件前3行:ca ...

  3. Linux下提权常用小命令

    有些新手朋友在拿到一个webshell后如果看到服务器是Linux或Unix操作系统的就直接放弃提权,认为Linux或Unix下的提权很难,不是大家能做的,其实Linux下的提权并没有很多人想象的那么 ...

  4. Linux 基础操作、常用shell命令、vi常用命令、man帮助手册

    Linux 基础操作.常用shell命令.vi常用命令.man帮助手册 一.简述 记录简单的Linux 基础操作.常用shell命令.vi编辑器常用命令.man帮助手册的使用. 二.Linux 基础操 ...

  5. Linux系统四种常用关机命令

    文章目录 一.halt命令 二.shutdown命令 三.poweroff命令 四.init命令 总结 一.halt命令 语法:halt [-n] [-w] [-d] [-f] [-i] [-p] 参 ...

  6. 总结Linux基础知识和常用渗透命令!!!

    作为Web渗透的初学者,Linux基础知识和常用命令是我们的必备技能,本文详细讲解了Linux相关知识点及Web渗透免了高龄.如果想玩好Kali或渗透,你需要学好Linux及相关命令,以及端口扫描.漏 ...

  7. Linux性能监控的常用工具/命令

    1. top - Linux系统进程监控 top命令是性能监控程序,他是Linux系统管理员经常使用的监控系统性能的工具.top命令可以定期显示所有正在运行和实际运行并且更新到列表中,它显示出 CPU ...

  8. linux下Hbase的常用shell命令

    本文作者:合肥工业大学 管理学院 钱洋 email:1563178220@qq.com 目录 linux下查看hbase的安装路径 HBase Shell和HBase交互 HBase常用shell语句 ...

  9. linux ftp解压命令 cannot fid or open,Linux环境搭建及常用shell命令集锦

    22.crontab –l 查看crontab命令行 (13) 23.重定向 (13) 24.ps –eaf | grep httpd 查找httpd进程 (13) 25.kill -9 PID 强制 ...

最新文章

  1. mysql 安装卸载_MySQL(一)——安装、卸载以及基本操作
  2. git config命令使用
  3. 节能无线信标Ver0:功率测试
  4. php vo,$vo.id php
  5. sklearn数据预处理-scale
  6. 5月22日云栖精选夜读:PHP学习路线图
  7. 一文看懂微服务背后的技术演进与应用实践
  8. JAVA/JSP学习系列之Resin+Apache安装
  9. WIN10 开启右键 命令提示符
  10. 【Node】—nodemon的简单使用
  11. 【安全牛学习笔记】手动漏洞挖掘(二)
  12. 高考数学必背公式整理[衡水中学高中数学组]
  13. 如何制作家庭网络服务器,如何用一个废旧的笔记本打造一个家庭网络服务器?...
  14. Python还在原地踏步?今天女友程序员教你函数的定义与使用
  15. typora 有道云笔记_利用神器Typora+PicGo,实现有道云不用会...
  16. php本地文件包含 截断,php远程文件包含截断问题
  17. 断章取义:关于红玫瑰和白玫瑰
  18. 最大公约数 / 最小公倍数
  19. html5 单元格宽度,html table呈现个人简历以及单元格宽度失效的问题解决
  20. 两个坐标系转换的变换矩阵

热门文章

  1. JDK1.8 中文文档下载与在线阅读
  2. tensorflow 各个版本的 CUDA 以及 Cudnn 版本对应关系
  3. Mybatis中的updateByPrimaryKeySelective()和updateByPrimaryKey()
  4. 【Python】os库的使用
  5. zuul集成cloud_如何在具有持续集成的Google Cloud Run上运行Laravel-分步指南
  6. 响应式滑动菜单_如何创建响应式滑动菜单
  7. 如何将应用程序分为三个主要层
  8. npm 缓存_npm缓存:无名英雄
  9. springMVC使用与生成序列号
  10. 尚学堂java答案解析 第三章