linux命令行编程参数 linux编程命令大全

Linux命令行操作之sedsed命令行格式:sed [options] 'command' file(s)
options常用选项:
-n或--quiet或——silent:仅显示script处理后的结果;
-e:以选项中的指定的script来处理输入的文本文件;
-f:以选项中指定的script文件来处理输入的文本文件;
-r∶sed 的动作支援的是延伸型正规表示法的语法;
-i∶直接修改读取的档案内容 , 而不是由萤幕输出;
-h或--help:显示帮助;
-V或--version:显示版本信息 。
Command常用命令:
a:新增,a 的后面可以接字符串,而这些字符串会在新的一行出现(目前的下一行);
c:取代,c 的后面可以接字符串,这些字符串可以取代 n1.n2 之间的行;
d:删除,d 后面通常不接任何字符串;
i:插入,i 的后面可以接字符串,而这些字符串会在新的一行出现(目前的上一行);
p:列印,亦即将某个选择的资料印出 。通常 p 会与参数 sed -n 一起运作;
s:取代,可以直接进行取代的工作,通常与正规表达式搭配使用 。
实例说明:
新增操作:a命令
sed '/^bird/a\test' file将test追加到 以bird开头的行后面
删除操作:d命令
sed '/^$/d' file #删除空白行;
sed '2d' file #删除第二行;
sed '2.$d' file #删除第2行到最后一行;
sed '$d' file #删除最后一行;
sed '/^bird/'d file #删除所有开头是bird的行;
插入操作:i命令
sed -i '3i\bird ' bird.conf #在bird.conf文件第3行之前插入bird
替换文本中的字符串:s命令
sed 's/bird/birds/' file #将文本中的bird替换成birds;
sed -i 's/ bird / birds /g' file #将file文件中每一行的第一个bird替换为birds;
linux命令 怎么实现使用参数#!/bin/bash
echo "This is script show the param use:"
echo "This is the script name: $0"
echo "This is the firstparam is: $1"
echo "This is the secondparam is: $2"
echo "This is the thirdparam is: $3"
echo "This is the fourthparam is: $4"
echo "This is the fifthparam is: $5"
echo "This is the sixthparam is: $6"
echo "This is the seventhparam is: $7"
echo "This is the eighthparam is: $8"
echo "This is the ninithparam is: $9"
echo "This totalparam num is: $#"
echo "This totalparam is: $*"
使用的时候直接把你要参数加到脚本后面例如下面:
[kinyou_xy@localhost shell]$ sh param.sh one two thr good night wubi shell study last
This is script show the param use:
This is the script name: param.sh
This is the firstparam is: one
This is the secondparam is: two
This is the thirdparam is: thr
This is the fourthparam is: good
This is the fifthparam is: night
This is the sixthparam is: wubi
This is the seventhparam is: shell
This is the eighthparam is: study
This is the ninithparam is: last
This totalparam num is: 9
This totalparam is: one two thr good night wubi shell study last
Linux 命令行技巧ALT快捷键在WIN下Xshell不可用
ctrla光标切换到命令行行首
ctrle光标切换到命令行末尾
ctrll清屏 等同于 clear
ctrlu清除剪切光标之前的内容
ctrlk清楚剪切光标之后的内容
ctrlw清除剪切光标之前的一个word
altd清除剪切光标之后的一个word
ctrly粘贴刚才删除字符
ctrlh向行首删除一个字符
ctrld向行尾删除一个字符,空行时等于 exit 和 logout
ctrl_恢复刚操作的命令 xshell无法使用
ctrlb光标向行首移动一个字符 ( backwards )
ctrlf光标向行尾移动一个字符( forwards )
ctrl←光标向行首移动一个word
ctrl→光标向行尾移动一个word
ctrlr历史命令中查找 (关键字可用)
ctrlz转入后台运行
history 10显示最近使用过的10个命令
!!执行前一个命令
!字符执行前一个以“字符”开头的命令
!Num执行对应行号的命令
!? abc执行前一个包含abc的命令
! -n执行n个命令之前的那个命令
!*调用上一条命令的所有参数
!$调用上一条命令的最后一个参数
!-:调用上一条命令除了最后一个参数的部分
ALTnum.调用上一条命令中任意一个部分
!!:gs/$1/$2替换上一条命令中所有$1为$2
!!:gs^$1^$2替换上一条命令中第一个$1为$2
【linux命令行编程参数 linux编程命令大全】关于linux命令行编程参数和linux编程命令大全的介绍到此就结束了 , 不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读