通常sed指令修改行内容时使用:sed -i " 9 s/^.*/"type in what you want modified!"/" 其中"type in what you want modified!"为替换后希望得到的内容. 由于用作替换的字符串里面不包括与sed替换格式相同的"/",因此可以正常使用. But,当希望通过sed方式修改配置文件中的目录时,由于用作替换的目录字符换(datapath=/home/data
(一)通过vi编辑器来替换.vi/vim 中可以使用 :s 命令来替换字符串.:s/well/good/ 替换当前行第一个 well 为 good:s/well/good/g 替换当前行所有 well 为 good:n,$s/well/good/ 替换第 n 行开始到最后一行中每一行的第一个 well 为 good:n,$s/well/good/g 替换第 n 行开始到最后一行中每一行所有 well 为 goodn 为数字,若 n 为 .,表示从当前行开始到最后一行:%s/well/good/(
Ubuntu14.04 给定一个文本,统计其中单词出现的次数 方法1 # solution 1 grep与awk配合使用,写成一个sh脚本 fre.sh sh fre.sh wordfretest.txt #! /bin/bash# solution 1 ] then echo "Usage:$0 args error" exit fi ] then echo "analyse the first file $1" fi #get the first file fi
sed -e 4a\newLine testfile 首先查看testfile中的内容如下: $ cat testfile #查看testfile 中的内容 HELLO LINUX! Linux is a free unix-type opterating system. This is a linux testfile! Linux test 使用sed命令后,输出结果如下: $ sed -e 4a\newline testfile #使用sed 在第四行后添加新字符串 HELLO LINUX