[~/shell]$ cat one.sh 
#!/bin/bash
path=/root/shell/test.txt
if [ ! -f $path ]  //检测文件是否存在,如果不存在,把内容改为ip为123then
    echo "addr:192.168.1.123 masknet:255.255.255.0 dns:192.168.1.1">test.txt
else    //存在,修改内容为ip为100echo "addr:192.168.1.100 masknet:255.255.255.0 dns:192.168.1.1">$path
fi
cat $path |sed 's/ /:/g'|awk -F: '{print $2","$4","$6}'    //cat命令懂吧,sed 那里是把空格换成:也晓得吧,awk那里以:作为分割符号,打印第246域的值
[~/shell]$ 

相关文章:

  • 2022-12-23
  • 2021-10-17
  • 2021-04-25
  • 2022-12-23
  • 2021-09-20
  • 2022-12-23
  • 2021-07-10
  • 2021-06-28
猜你喜欢
  • 2022-02-09
  • 2021-07-19
  • 2021-09-30
  • 2021-11-26
  • 2021-07-22
  • 2021-08-30
  • 2021-08-11
相关资源
相似解决方案