touch

更改文件时间戳,更改指定文件的访问或修改时间。
不存在的文件将会被创建为空文件,除非使用-c 或-h 选项

语法

  touch [options]... File...

选项


-a
--time=atime
--time=access
--time=use
     仅更改访问时间

-c
--no-create
    不要创建不存在的文件。

-d
--date=time
     使用指定字符串表示时间替代当前时间

-f   忽略,与BSD版本的“touch”兼容。

-m
--time=mtime
--time=modify
     仅更改修改时间。

-r FILE
--reference=FILE
    使用引用FILE的时间而不是当前时间。

-t [[CC]YY]MMDDhhmm[.ss]
     设置为指定时间。

例子

创建/标记一个名为sample.txt的文件:

touch sample.txt

创建10个文件file1, file2 等:

 touch file{1,2,3,4,5,6,7,8,9,10}

touch 命令实例:

linux命令:touch -d '-1 year' /tmp/oldfile /tmp/oldfile year' '-1 -d touch touch -d '-1 year' /tmp/oldfilerootopen.com
linux命令:touch -d '-1 year' /tmp/oldfile /tmp/oldfile year' '-1 -d touch touch -d '-1 year' /tmp/oldfilerootopen.com
2019-06-04 22:15:05

linux命令:touch -acm yyyymmddhhMM.ss [file] [file] yyyymmddhhMM.ss -acm touch touch -acm yyyymmddhhMM.ss [file]rootopen.com
linux命令:touch -acm yyyymmddhhMM.ss [file] [file] yyyymmddhhMM.ss -acm touch touch -acm yyyymmddhhMM.ss [file]rootopen.com
2018-02-28 02:44:48

linux命令:touch /forcefsk /forcefsk touch touch /forcefskrootopen.com
linux命令:touch /forcefsk /forcefsk touch touch /forcefskrootopen.com
2018-05-06 02:44:48

linux命令:touch <filename> <filename> touch touch <filename>rootopen.com
linux命令:touch <filename> <filename> touch touch <filename>rootopen.com
2018-03-07 06:16:48

linux命令:touch balls balls touch touch ballsrootopen.com
linux命令:touch balls balls touch touch ballsrootopen.com
2018-05-31 06:52:48

linux命令:touch /tmp/$$;for N in `seq -w 0 7777|grep -v [89]`; do chmod $N /tmp/$$; P=`ls -l /tmp/$$ | awk '{print $1}'`; echo $N $P; done;rm /tmp/$$ /tmp/$$ done;rm $P; $N echo $1}'`; '{print awk | /tmp/$$ -l P=`ls /tmp/$$; $N chmod do [89]`; -v 7777|grep 0 -w `seq in N /tmp/$$;for touch touch /tmp/$$;for N in `seq -w 0 7777|grep -v [89]`; do chmod $N /tmp/$$; P=`ls -l /tmp/$$ | awk '{print $1}'`; echo $N $P; done;rm /tmp/$$rootopen.com
linux命令:touch /tmp/$$;for N in `seq -w 0 7777|grep -v [89]`; do chmod $N /tmp/$$; P=`ls -l /tmp/$$ | awk '{print $1}'`; echo $N $P; done;rm /tmp/$$ /tmp/$$ done;rm $P; $N echo $1}'`; '{print awk | /tmp/$$ -l P=`ls /tmp/$$; $N chmod do [89]`; -v 7777|grep 0 -w `seq in N /tmp/$$;for touch touch /tmp/$$;for N in `seq -w 0 7777|grep -v [89]`; do chmod $N /tmp/$$; P=`ls -l /tmp/$$ | awk '{print $1}'`; echo $N $P; done;rm /tmp/$$rootopen.com
2018-01-08 10:49:48

linux命令:touch {1..10}.txt {1..10}.txt touch touch {1..10}.txtrootopen.com
linux命令:touch {1..10}.txt {1..10}.txt touch touch {1..10}.txtrootopen.com
2018-03-08 13:59:48

linux命令:touch /etc/nologin /etc/nologin touch touch /etc/nologinrootopen.com
linux命令:touch /etc/nologin /etc/nologin touch touch /etc/nologinrootopen.com
2018-02-05 11:32:48

linux命令:touch -amct [[CC]YY]MMDDhhmm[.ss] FILE FILE [[CC]YY]MMDDhhmm[.ss] -amct touch touch -amct [[CC]YY]MMDDhhmm[.ss] FILErootopen.com
linux命令:touch -amct [[CC]YY]MMDDhhmm[.ss] FILE FILE [[CC]YY]MMDDhhmm[.ss] -amct touch touch -amct [[CC]YY]MMDDhhmm[.ss] FILErootopen.com
2018-03-13 19:49:48

linux命令:touch $2;firefox -print $1 -printmode PDF -printfile $2 $2 -printfile PDF -printmode $1 -print $2;firefox touch touch $2;firefox -print $1 -printmode PDF -printfile $2rootopen.com
linux命令:touch $2;firefox -print $1 -printmode PDF -printfile $2 $2 -printfile PDF -printmode $1 -print $2;firefox touch touch $2;firefox -print $1 -printmode PDF -printfile $2rootopen.com
2018-02-12 18:11:48

linux命令:touch $2;firefox -print $1 -printmode PNG -printfile $2 $2 -printfile PNG -printmode $1 -print $2;firefox touch touch $2;firefox -print $1 -printmode PNG -printfile $2rootopen.com
linux命令:touch $2;firefox -print $1 -printmode PNG -printfile $2 $2 -printfile PNG -printmode $1 -print $2;firefox touch touch $2;firefox -print $1 -printmode PNG -printfile $2rootopen.com
2018-01-09 02:32:48

linux命令:touch /tmp/file ; $EXECUTECOMMAND ; find /path -newer /tmp/file /tmp/file -newer /path find ; $EXECUTECOMMAND ; /tmp/file touch touch /tmp/file ; $EXECUTECOMMAND ; find /path -newer /tmp/filerootopen.com
linux命令:touch /tmp/file ; $EXECUTECOMMAND ; find /path -newer /tmp/file /tmp/file -newer /path find ; $EXECUTECOMMAND ; /tmp/file touch touch /tmp/file ; $EXECUTECOMMAND ; find /path -newer /tmp/filerootopen.com
2018-05-03 09:43:48

linux命令:touch -r "$FILE1" "$FILE2" "$FILE2" "$FILE1" -r touch touch -r "$FILE1" "$FILE2"rootopen.com
linux命令:touch -r "$FILE1" "$FILE2" "$FILE2" "$FILE1" -r touch touch -r "$FILE1" "$FILE2"rootopen.com
2018-05-04 23:27:48

linux命令:touch -t "YYYYMMDDhhmm.ss" dummy ; find . -anewer dummy dummy -anewer . find ; dummy "YYYYMMDDhhmm.ss" -t touch touch -t "YYYYMMDDhhmm.ss" dummy ; find . -anewer dummyrootopen.com
linux命令:touch -t "YYYYMMDDhhmm.ss" dummy ; find . -anewer dummy dummy -anewer . find ; dummy "YYYYMMDDhhmm.ss" -t touch touch -t "YYYYMMDDhhmm.ss" dummy ; find . -anewer dummyrootopen.com
2018-05-27 11:16:48

linux命令:touch file-$(date +%Y%m%d) +%Y%m%d) file-$(date touch touch file-$(date +%Y%m%d)rootopen.com
linux命令:touch file-$(date +%Y%m%d) +%Y%m%d) file-$(date touch touch file-$(date +%Y%m%d)rootopen.com
2018-05-06 15:07:48

linux命令:touch -t "YYYYMMDDhhmm.ss" ~/.ts ; find . -newer ~/.ts ~/.ts -newer . find ; ~/.ts "YYYYMMDDhhmm.ss" -t touch touch -t "YYYYMMDDhhmm.ss" ~/.ts ; find . -newer ~/.tsrootopen.com
linux命令:touch -t "YYYYMMDDhhmm.ss" ~/.ts ; find . -newer ~/.ts ~/.ts -newer . find ; ~/.ts "YYYYMMDDhhmm.ss" -t touch touch -t "YYYYMMDDhhmm.ss" ~/.ts ; find . -newer ~/.tsrootopen.com
2018-02-04 21:10:48

linux命令:touch /path/to/file.txt /path/to/file.txt touch touch /path/to/file.txtrootopen.com
linux命令:touch /path/to/file.txt /path/to/file.txt touch touch /path/to/file.txtrootopen.com
2018-03-01 12:15:48

linux命令:touch file file touch touch filerootopen.com
linux命令:touch file file touch touch filerootopen.com
2018-01-11 15:28:48

linux命令:touch pk.pem && chmod 600 pk.pem && openssl genrsa -out pk.pem 2048 && openssl req -new -batch -key pk.pem | openssl x509 -req -days 365 -signkey pk.pem -out cert.pem cert.pem -out pk.pem -signkey 365 -days -req x509 openssl | pk.pem -key -batch -new req openssl && 2048 pk.pem -out genrsa openssl && pk.pem 600 chmod && pk.pem touch touch pk.pem && chmod 600 pk.pem && openssl genrsa -out pk.pem 2048 && openssl req -new -batch -key pk.pem | openssl x509 -req -days 365 -signkey pk.pem -out cert.pemrootopen.com
linux命令:touch pk.pem && chmod 600 pk.pem && openssl genrsa -out pk.pem 2048 && openssl req -new -batch -key pk.pem | openssl x509 -req -days 365 -signkey pk.pem -out cert.pem cert.pem -out pk.pem -signkey 365 -days -req x509 openssl | pk.pem -key -batch -new req openssl && 2048 pk.pem -out genrsa openssl && pk.pem 600 chmod && pk.pem touch touch pk.pem && chmod 600 pk.pem && openssl genrsa -out pk.pem 2048 && openssl req -new -batch -key pk.pem | openssl x509 -req -days 365 -signkey pk.pem -out cert.pemrootopen.com
2018-04-15 01:12:48

linux命令:touch file{1,2,3,4,5}.sh file{1,2,3,4,5}.sh touch touch file{1,2,3,4,5}.shrootopen.com
linux命令:touch file{1,2,3,4,5}.sh file{1,2,3,4,5}.sh touch touch file{1,2,3,4,5}.shrootopen.com
2018-03-06 08:29:48

linux命令:touch -t 201001010000 begin; touch -t 201012312359.59 end; find . -newer begin -a ! -newer end end -newer ! -a begin -newer . find end; 201012312359.59 -t touch begin; 201001010000 -t touch touch -t 201001010000 begin; touch -t 201012312359.59 end; find . -newer begin -a ! -newer endrootopen.com
linux命令:touch -t 201001010000 begin; touch -t 201012312359.59 end; find . -newer begin -a ! -newer end end -newer ! -a begin -newer . find end; 201012312359.59 -t touch begin; 201001010000 -t touch touch -t 201001010000 begin; touch -t 201012312359.59 end; find . -newer begin -a ! -newer endrootopen.com
2018-05-01 12:13:48

linux命令:touch -t [[CC]AA]MMJJhhmm[.ss] [[CC]AA]MMJJhhmm[.ss] -t touch touch -t [[CC]AA]MMJJhhmm[.ss]rootopen.com
linux命令:touch -t [[CC]AA]MMJJhhmm[.ss] [[CC]AA]MMJJhhmm[.ss] -t touch touch -t [[CC]AA]MMJJhhmm[.ss]rootopen.com
2018-03-19 18:28:48

linux命令:touch --date "2010-01-05" /tmp/filename /tmp/filename "2010-01-05" --date touch touch --date "2010-01-05" /tmp/filenamerootopen.com
linux命令:touch --date "2010-01-05" /tmp/filename /tmp/filename "2010-01-05" --date touch touch --date "2010-01-05" /tmp/filenamerootopen.com
2018-03-09 01:31:48

linux命令:touch -d $(zenity --calendar --date-format=%F) filename filename --date-format=%F) --calendar $(zenity -d touch touch -d $(zenity --calendar --date-format=%F) filenamerootopen.com
linux命令:touch -d $(zenity --calendar --date-format=%F) filename filename --date-format=%F) --calendar $(zenity -d touch touch -d $(zenity --calendar --date-format=%F) filenamerootopen.com
2018-02-18 23:17:48

linux命令:touch -t 201208211200 first ; touch -t 201208220100 last ; find /path/to/files/ -newer first ! -newer last | xargs -ifile mv -fv file /path/to/destination/ ; rm first; rm last; last; rm first; rm ; /path/to/destination/ file -fv mv -ifile xargs | last -newer ! first -newer /path/to/files/ find ; last 201208220100 -t touch ; first 201208211200 -t touch touch -t 201208211200 first ; touch -t 201208220100 last ; find /path/to/files/ -newer first ! -newer last | xargs -ifile mv -fv file /path/to/destination/ ; rm first; rm last;rootopen.com
linux命令:touch -t 201208211200 first ; touch -t 201208220100 last ; find /path/to/files/ -newer first ! -newer last | xargs -ifile mv -fv file /path/to/destination/ ; rm first; rm last; last; rm first; rm ; /path/to/destination/ file -fv mv -ifile xargs | last -newer ! first -newer /path/to/files/ find ; last 201208220100 -t touch ; first 201208211200 -t touch touch -t 201208211200 first ; touch -t 201208220100 last ; find /path/to/files/ -newer first ! -newer last | xargs -ifile mv -fv file /path/to/destination/ ; rm first; rm last;rootopen.com
2018-04-27 02:31:48

linux命令:touch filename filename touch touch filenamerootopen.com
linux命令:touch filename filename touch touch filenamerootopen.com
2018-03-25 12:56:48

linux命令:touch ~/.hushlogin ~/.hushlogin touch touch ~/.hushloginrootopen.com
linux命令:touch ~/.hushlogin ~/.hushlogin touch touch ~/.hushloginrootopen.com
2018-01-01 09:04:48

linux命令:touch file{1..10}.txt ; ls *txt| sed -e "p;s/\.txt$/\.csv/"|xargs -n2 mv mv -n2 "p;s/\.txt$/\.csv/"|xargs -e sed *txt| ls ; file{1..10}.txt touch touch file{1..10}.txt ; ls *txt| sed -e "p;s/\.txt$/\.csv/"|xargs -n2 mvrootopen.com
linux命令:touch file{1..10}.txt ; ls *txt| sed -e "p;s/\.txt$/\.csv/"|xargs -n2 mv mv -n2 "p;s/\.txt$/\.csv/"|xargs -e sed *txt| ls ; file{1..10}.txt touch touch file{1..10}.txt ; ls *txt| sed -e "p;s/\.txt$/\.csv/"|xargs -n2 mvrootopen.com
2018-01-19 05:59:48

linux命令:touch -r "source_file" "destination_file" "destination_file" "source_file" -r touch touch -r "source_file" "destination_file"rootopen.com
linux命令:touch -r "source_file" "destination_file" "destination_file" "source_file" -r touch touch -r "source_file" "destination_file"rootopen.com
2018-04-23 16:30:48

linux命令:touch -t 197001010000 ./tmp && find . -newer ./tmp && rm -f ./tmp ./tmp -f rm && ./tmp -newer . find && ./tmp 197001010000 -t touch touch -t 197001010000 ./tmp && find . -newer ./tmp && rm -f ./tmprootopen.com
linux命令:touch -t 197001010000 ./tmp && find . -newer ./tmp && rm -f ./tmp ./tmp -f rm && ./tmp -newer . find && ./tmp 197001010000 -t touch touch -t 197001010000 ./tmp && find . -newer ./tmp && rm -f ./tmprootopen.com
2018-05-21 14:57:48

linux命令:touch .tardis; the command ; find . -newer .tardis; rm .tardis; .tardis; rm .tardis; -newer . find ; command the .tardis; touch touch .tardis; the command ; find . -newer .tardis; rm .tardis;rootopen.com
linux命令:touch .tardis; the command ; find . -newer .tardis; rm .tardis; .tardis; rm .tardis; -newer . find ; command the .tardis; touch touch .tardis; the command ; find . -newer .tardis; rm .tardis;rootopen.com
2018-05-12 17:29:48

linux命令:touch files.txt; cat reorder_files.sh | while read line; do x=`echo $line | sed 's/touch \([a-z0-9\.]\+.*.pdf\);.*/\1/'`; echo $x >> files.txt ; done; done; ; files.txt >> $x echo \([a-z0-9\.]\+.*.pdf\);.*/\1/'`; 's/touch sed | $line x=`echo do line; read while | reorder_files.sh cat files.txt; touch touch files.txt; cat reorder_files.sh | while read line; do x=`echo $line | sed 's/touch \([a-z0-9\.]\+.*.pdf\);.*/\1/'`; echo $x >> files.txt ; done;rootopen.com
linux命令:touch files.txt; cat reorder_files.sh | while read line; do x=`echo $line | sed 's/touch \([a-z0-9\.]\+.*.pdf\);.*/\1/'`; echo $x >> files.txt ; done; done; ; files.txt >> $x echo \([a-z0-9\.]\+.*.pdf\);.*/\1/'`; 's/touch sed | $line x=`echo do line; read while | reorder_files.sh cat files.txt; touch touch files.txt; cat reorder_files.sh | while read line; do x=`echo $line | sed 's/touch \([a-z0-9\.]\+.*.pdf\);.*/\1/'`; echo $x >> files.txt ; done;rootopen.com
2018-02-04 18:33:48

Linux的Bash命令行(A-Z排序)