1.将指定内容写入文件
echo "hello world" > file.txt
echo "hello world" >> file.txt //上面那个是覆盖,这个是追加
2.读取文件内容
写法一:----------------------------------------------------------------------------#!/bin/bashwhile read linedo echo $linedone < file(待读取的文件)----------------------------------------------------------------------------写法二:----------------------------------------------------------------------------#!/bin/bashcat file(待读取的文件) | while read linedo echo $linedone----------------------------------------------------------------------------写法三:----------------------------------------------------------------------------for line in `cat file(待读取的文件)`do echo $linedone----------------------------------------------------------------------------说明:for逐行读和while逐行读是有区别的,如:$ cat fileaaaabbbbcccc dddd$ cat file | while read line; do echo $line; doneaaaabbbbcccc dddd$ for line in $(
3.杀死某个程序的所有进程,grep后面添加杀死的条件
kill -9 `ps -ef | grep process_name | grep -v "grep" | awk '{print $2}'`