“Linux-2018-spring-4-17”的版本间的差异

来自SUDA-HLT
跳到导航 跳到搜索
(创建页面,内容为“一、回顾上节课内容: *查看帮助文档 man、info、help 二、补充shell中操作命令 *shell本身也是一种编程语言 *查看内部命令(...”)
 
第24行: 第24行:
 
       fc fix command/history修改命令
 
       fc fix command/history修改命令
  
三、shell种的wildcard 通配符
+
三、shell中的wildcard 通配符
*?匹配任意一个字符 *匹配任意长度个任意字符 ;[abcd]匹配中括号中的某一个字符;[a-z]匹配一个范围
+
*?匹配任意一个字符; *匹配任意长度个任意字符;[abcd]匹配中括号中的某一个字符;[a-z]匹配一个范围
 
     $ls /bin/?a???
 
     $ls /bin/?a???
 
     $ls /bin/f*
 
     $ls /bin/f*
 
     $ls /[cd]*  :匹配中括号中的某一个字符开头的文件
 
     $ls /[cd]*  :匹配中括号中的某一个字符开头的文件
 +
*shell来处理的通配符
 +
    $ls home/*:相当于ls /home/zhenghua /home/yli /home/a.txt
 +
    $ls -d /home/*:不显示文件夹内的东西
 +
    $cp *.txt xxx
  
四、重定义
+
四、重定向
 +
*标准输入重定向 stdin--->file
 +
 
 +
*标准输出重定向 stdout--->file
 +
 
 +
输出重定向:
 +
 
 +
  argc:参数的个数
 +
  argv:字符串数组;argv[0]:命令本身
 +
 
 +
  $gcc main.c -o hi
 +
 
 +
  $./hi hello dads dff
 +
 
 +
0:./hi
 +
1:hello
 +
2: dads
 +
3:dff
 +
I am stderr
 +
 
 +
  $./hi hello dads dff > yy.txt
 +
 
 +
只输出标准错误输出stderr:I am stderr
 +
 
 +
  $./hi hello dads dff >> yy.tx 追加
 +
 
 +
  $./hi hello dads dff > yy.tx 2>&1:标准错误的输出也写入了yy.txt中
 +
stdin=0;stdout=1;stderr=2
 +
 
 +
ctrl+c:杀死进程
 +
 
 +
ctrl+d:"EOF"x信号
 +
$./hi < main.c :标准输入重定向

2018年4月17日 (二) 06:21的版本

一、回顾上节课内容:

  • 查看帮助文档
  man、info、help

二、补充shell中操作命令

  • shell本身也是一种编程语言
  • 查看内部命令(man、help)
   $man bash/builtins:查看内部命令
    输入“/^\s+history”正则表达式搜索
   $history:显示之前输入的所有命令
   $fc -s love=hate 232 替换232命令中的love为hate
   $help ./: 查看.命令或者:命令
  • 管道
   屏幕对应的文件:标准输入输出stdin;stdout;stderr
   $help history |less 分屏显示
   $clear或者 ctrl+l:清屏
   ctrl+a回到命令的最开始
   ctrl+e回到命令的最末尾
   ctrl+u清除一行的命令    

注:“tab”键,自动补全文件名、命令名

     bg background后台
     fg fore ground前台
     fc fix command/history修改命令

三、shell中的wildcard 通配符

  • ?匹配任意一个字符; *匹配任意长度个任意字符;[abcd]匹配中括号中的某一个字符;[a-z]匹配一个范围
   $ls /bin/?a???
   $ls /bin/f*
   $ls /[cd]*  :匹配中括号中的某一个字符开头的文件
  • shell来处理的通配符
   $ls home/*:相当于ls /home/zhenghua /home/yli /home/a.txt
   $ls -d /home/*:不显示文件夹内的东西
   $cp *.txt xxx

四、重定向

  • 标准输入重定向 stdin--->file
  • 标准输出重定向 stdout--->file

输出重定向:

  argc:参数的个数
  argv:字符串数组;argv[0]:命令本身
  $gcc main.c -o hi
  $./hi hello dads dff

0:./hi 1:hello 2: dads 3:dff I am stderr

  $./hi hello dads dff > yy.txt

只输出标准错误输出stderr:I am stderr

  $./hi hello dads dff >> yy.tx 追加
  $./hi hello dads dff > yy.tx 2>&1:标准错误的输出也写入了yy.txt中

stdin=0;stdout=1;stderr=2

ctrl+c:杀死进程

ctrl+d:"EOF"x信号 $./hi < main.c :标准输入重定向