Transfer changed files: Difference between revisions

From MK Wiki EN
Jump to navigation Jump to search
m (2 revisions imported)
 
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:


  cd '''/path'''
  cd '''/path'''
  tar cfz `date +%Y%m%d_%H%M%S`.tar.gz `find . -mtime -'''20''' -type f -name "*"`
  tar cfz `date -u +%Y%m%d_%H%M%S`.tar.gz `find . -mtime -'''20''' -type f -name "*"`


[http://www.linuxquestions.org/questions/linux-newbie-8/tar-files-in-a-dir-modified-before-7-days-in-a-shell-script-175836/#post905172 Credits] (slightly modified)
[http://www.linuxquestions.org/questions/linux-newbie-8/tar-files-in-a-dir-modified-before-7-days-in-a-shell-script-175836/#post905172 Credits] (slightly modified)


'''Explanation:''' find all files that have been modified (mtime) in the recent '''20''' days and put them into a tar.gz-file whose name represents the current date and time.
'''Explanation:''' find all files that have been modified (mtime) in the recent '''20''' days and put them into a tar.gz-file whose name represents the current date and time (UTC).
 
Alternative:
 
tar cfz `date -u +%Y%m%d_%H%M%S`.tar.gz `find . -newermt "2022-12-02" ! -newermt "2022-12-05" -type f -name "*"`
 
Finds all files modified between 2022-12-02 and 2022-12-05.
 
Credits: [https://stackoverflow.com/a/23508622/3424360 StackOverflow: Find files created in a date range]


== untar files on destination computer ==
== untar files on destination computer ==
Line 12: Line 20:
  cd '''/path'''
  cd '''/path'''
  tar -zxvf '''name-of-file.tar.gz'''
  tar -zxvf '''name-of-file.tar.gz'''
[[Category:Linux]]

Latest revision as of 11:06, 22 January 2023

tar files on computer with modified file

cd /path
tar cfz `date -u +%Y%m%d_%H%M%S`.tar.gz `find . -mtime -20 -type f -name "*"`

Credits (slightly modified)

Explanation: find all files that have been modified (mtime) in the recent 20 days and put them into a tar.gz-file whose name represents the current date and time (UTC).

Alternative:

tar cfz `date -u +%Y%m%d_%H%M%S`.tar.gz `find . -newermt "2022-12-02" ! -newermt "2022-12-05" -type f -name "*"`

Finds all files modified between 2022-12-02 and 2022-12-05.

Credits: StackOverflow: Find files created in a date range

untar files on destination computer

cd /path
tar -zxvf name-of-file.tar.gz