prepend
来自「伯克利做的SFTP安全文件传输协议」· 代码 · 共 35 行
TXT
35 行
#! /bin/csh -f# script to prepend a single line of text to a text fileif ( "$2" == "" ) then echo "usage: $0 filename line-to-prepend" exitendif# grab filenameset fname = $1# shift arguments, so $* can refer to everythingshift# if file doesn't exist, just create it and bailif ( -e $fname ) then # it existselse echo $* > $fname exitendif# copy the existing file to a temporary file ($$ is pid)set tmp = /tmp/prepend.$$mv $fname $tmp# write the first lineecho $* > $fname# append the remainder of the original filecat $tmp >> $fname# remove the temporary filerm $tmp
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?