#!/bin/sh
/sbin/ifconfig tun0 | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}' > ./tun0_ip.txt
当我将它放入命令行时,这非常有效。但是它不适用于 sh 脚本。
我究竟做错了什么?为什么某些命令不适用于 sh 脚本?
~$ bash -x ./reset.sh
+ echo /sbin/ifconfig tun0
+ grep 'inet addr:'
+ cut -d: -f2
+ awk '{print $1}'