假设有文件test.txt,想把test.txt文件第三列含有的good替换为bye,并把替换后的文件保存为test_bye.txt,只需要如下命令. test.txt go go good go my my go good bye my good bye test_bye.txt go go bye go my my go good bye my bye bye awk -F " " '{if ($3==good) $3=bye}1' test.txt > test_bye.t
1. 在/home/username/ 目录下新建一个目录,命名为:.trash 2.. 在/home/username/tools/目录下,新建一个shell文件,命名为: remove.sh #!/bin/bashPARA_CNT=$# TRASH_DIR="/home/username/.trash" for i in $*; do STAMP=`date +%s` fileName=`basename $i` mv $i $TRASH_DIR/$fileName.$STAMP
使用命令sed.cp.tail.cat 1.拷贝一个任意文件(生产环境切勿操作) cp /etc/profile /tmp 查看文件部分格式 cat /tmp/profile # /etc/profile # System wide environment and startup programs, for login setup # Functions and aliases go in /etc/bashrc # It's NOT a good idea to change this fil