sed怎样在最后一行添加?

2025-03-26 01:17:54
推荐回答(2个)
回答1:

1、echo “5 * * * * /root/crontab01” >> /tmp/root.crontab
2、sed -i '$a 5 * * * * /root/crontab01' /tmp/root.crontab
3、awk '{print $0} END{print “5 * * * * /root/crontab01”}' /tmp/root.crontab

回答2:

用echo更容易吧?
echo "5 * * * * /root/crontab01" >> /tmp/root.crontab