root@ubuntu:~# cat a 0 2 0 root@ubuntu:~# cat 1.sh line=$1 n_num=`sed -n "${line}p" a` num=`expr $n_num + 1` sed -i "${line}s/.*/$num/g" a cat a root@ubuntu:~# sh 1.sh 2 0 3 0 root@ubuntu:~# sh 1.sh 3 0 3 1