我在工作中管理数据已有 20 多年,我们一直使用用 unix 命令 tar 写入的磁带。这样做的副产品是 tar 目录,我将其存储起来以供从磁带检索文件时参考。我们最近开始使用 Beyond Compare 将文件从我们的实时服务器移动到与 Azure 云存储同步的 UNC 共享。我正在寻找一种方法来尽可能接近地复制 tar 输出表的外观和信息,以保持与我已经拥有的数千个表的连续性。
以下是格式的示例:
drwxrwsr-x myusername/domain users 0 2020-02-14 18:41 oldcomputer/
drwxrwsr-x myusername/domain users 0 2020-02-14 18:44 oldcomputer/6gu4hryi.default/
-rw-rw-r-- myusername/domain users 13795 2020-01-27 19:20 oldcomputer/6gu4hryi.default/abook.mab
-rw-rw-r-- myusername/domain users 16198 2020-02-14 13:43 oldcomputer/6gu4hryi.default/addons.json
-rw-rw-r-- myusername/domain users 1957 2020-01-30 13:46 oldcomputer/6gu4hryi.default/addonStartup.json.lz4
-rw-rw-r-- myusername/domain users 0 2020-01-30 13:46 oldcomputer/6gu4hryi.default/AlternateServices.txt
-rw-rw-r-- myusername/domain users 524288 2014-12-03 17:02 oldcomputer/6gu4hryi.default/blist.sqlite
-rw-rw-r-- myusername/domain users 575337 2018-11-26 19:53 oldcomputer/6gu4hryi.default/blocklist-addons.json
-rw-rw-r-- myusername/domain users 27953 2017-05-22 17:51 oldcomputer/6gu4hryi.default/blocklist-gfx.json
-rw-rw-r-- myusername/domain users 139100 2018-09-12 18:54 oldcomputer/6gu4hryi.default/blocklist-plugins.json
-rw-rw-r-- myusername/domain users 843726 2020-02-14 13:47 oldcomputer/6gu4hryi.default/blocklist.xml
-rw-rw-r-- myusername/domain users 163840 2018-12-06 18:43 oldcomputer/6gu4hryi.default/cert8.db
-rw-rw-r-- myusername/domain users 327680 2019-08-26 14:30 oldcomputer/6gu4hryi.default/cert9.db
-rw-rw-r-- myusername/domain users 208 2020-01-30 13:46 oldcomputer/6gu4hryi.default/compatibility.ini
-rw-rw-r-- myusername/domain users 229376 2019-12-09 13:51 oldcomputer/6gu4hryi.default/content-prefs.sqlite
-rw-rw-r-- myusername/domain users 524288 2020-02-14 13:49 oldcomputer/6gu4hryi.default/cookies.sqlite
-rw-rw-r-- myusername/domain users 32768 2020-01-30 13:46 oldcomputer/6gu4hryi.default/cookies.sqlite-shm
-rw-rw-r-- myusername/domain users 524704 2020-02-06 13:47 oldcomputer/6gu4hryi.default/cookies.sqlite-wal
-rw-rw-r-- myusername/domain users 23 2017-07-18 13:34 oldcomputer/6gu4hryi.default/directoryTree.json
-rw-rw-r-- myusername/domain users 972 2019-11-21 13:10 oldcomputer/6gu4hryi.default/extension-preferences.json
-rw-rw-r-- myusername/domain users 44697 2020-02-14 13:51 oldcomputer/6gu4hryi.default/extensions.json
-rw-rw-r-- myusername/domain users 5242880 2019-12-09 13:51 oldcomputer/6gu4hryi.default/favicons.sqlite
-rw-rw-r-- myusername/domain users 32768 2020-01-30 13:46 oldcomputer/6gu4hryi.default/favicons.sqlite-shm
-rw-rw-r-- myusername/domain users 0 2020-01-30 13:46 oldcomputer/6gu4hryi.default/favicons.sqlite-wal
-rw-rw-r-- myusername/domain users 3304 2020-01-30 13:46 oldcomputer/6gu4hryi.default/folderTree.json
-rw-rw-r-- myusername/domain users 196608 2014-12-03 17:06 oldcomputer/6gu4hryi.default/formhistory.sqlite
-rw-rw-r-- myusername/domain users 242614272 2020-02-14 17:08 oldcomputer/6gu4hryi.default/global-messages-db.sqlite
-rw-rw-r-- myusername/domain users 183894016 2016-10-24 12:21 oldcomputer/6gu4hryi.default/global-messages-db.sqlite.old
-rw-rw-r-- myusername/domain users 995 2019-11-25 13:12 oldcomputer/6gu4hryi.default/handlers.json
-rw-rw-r-- myusername/domain users 95639 2020-01-30 13:46 oldcomputer/6gu4hryi.default/history.mab
-rw-rw-r-- myusername/domain users 16384 2018-12-06 18:43 oldcomputer/6gu4hryi.default/key3.db
-rw-rw-r-- myusername/domain users 294912 2018-12-06 18:43 oldcomputer/6gu4hryi.default/key4.db
-rw-rw-r-- myusername/domain users 1900544 2019-11-15 12:53 oldcomputer/6gu4hryi.default/kinto.sqlite
-rw-rw-r-- myusername/domain users 22665 2015-08-24 19:13 oldcomputer/6gu4hryi.default/localstore.rdf
-rw-rw-r-- myusername/domain users 1717 2019-06-03 13:40 oldcomputer/6gu4hryi.default/logins.json
-rw-rw-r-- myusername/domain users 504 2014-12-03 17:02 oldcomputer/6gu4hryi.default/mailViews.dat
-rw-rw-r-- myusername/domain users 5676 2018-08-08 18:28 oldcomputer/6gu4hryi.default/mimeTypes.rdf
-rw-rw-r-- myusername/domain users 294597 2020-02-14 17:13 oldcomputer/6gu4hryi.default/panacea.dat
-rw-rw-r-- myusername/domain users 131072 2020-02-14 17:17 oldcomputer/6gu4hryi.default/permissions.sqlite
-rw-rw-r-- myusername/domain users 64 2016-07-25 12:51 oldcomputer/6gu4hryi.default/persdict.dat
-rw-rw-r-- myusername/domain users 906 2018-12-06 18:43 oldcomputer/6gu4hryi.default/pkcs11.txt
-rw-rw-r-- myusername/domain users 5242880 2020-02-12 18:44 oldcomputer/6gu4hryi.default/places.sqlite
-rw-rw-r-- myusername/domain users 32768 2020-01-30 13:46 oldcomputer/6gu4hryi.default/places.sqlite-shm
-rw-rw-r-- myusername/domain users 2262680 2020-02-12 22:02 oldcomputer/6gu4hryi.default/places.sqlite-wal
-rw-rw-r-- myusername/domain users 1475 2020-01-30 13:46 oldcomputer/6gu4hryi.default/pluginreg.dat
drwxrwsr-x myusername/domain users 0 2020-02-14 18:41 oldcomputer/6gu4hryi.default/blocklists/
-rw-rw-r-- myusername/domain users 879908 2019-11-15 12:53 oldcomputer/6gu4hryi.default/blocklists/addons.json
-rw-rw-r-- myusername/domain users 139100 2019-11-02 12:39 oldcomputer/6gu4hryi.default/blocklists/plugins.json
drwxrwsr-x myusername/domain users 0 2020-02-14 18:41 oldcomputer/6gu4hryi.default/calendar-data/
-rw-rw-r-- myusername/domain users 98304 2015-09-08 12:53 oldcomputer/6gu4hryi.default/calendar-data/deleted.sqlite
-rw-rw-r-- myusername/domain users 753664 2020-01-15 13:29 oldcomputer/6gu4hryi.default/calendar-data/local.sqlite
-rw-rw-r-- myusername/domain users 32768 2020-01-30 13:46 oldcomputer/6gu4hryi.default/calendar-data/local.sqlite-shm
-rw-rw-r-- myusername/domain users 0 2020-01-30 13:46 oldcomputer/6gu4hryi.default/calendar-data/local.sqlite-wal
drwxrwsr-x myusername/domain users 0 2020-02-14 18:41 oldcomputer/6gu4hryi.default/crashes/
-rw-rw-r-- myusername/domain users 66 2020-01-30 13:47 oldcomputer/6gu4hryi.default/crashes/store.json.mozlz4
drwxrwsr-x myusername/domain users 0 2015-08-26 13:40 oldcomputer/6gu4hryi.default/crashes/events/
drwxrwsr-x myusername/domain users 0 2020-02-14 18:41 oldcomputer/6gu4hryi.default/datareporting/
-rw-rw-r-- myusername/domain users 164 2019-11-21 06:00 oldcomputer/6gu4hryi.default/datareporting/session-state.json
-rw-rw-r-- myusername/domain users 51 2016-09-06 15:14 oldcomputer/6gu4hryi.default/datareporting/state.json
drwxrwsr-x myusername/domain users 0 2020-02-14 18:41 oldcomputer/6gu4hryi.default/extensions/
-rw-rw-r-- myusername/domain users 7069 2014-12-03 17:09 oldcomputer/6gu4hryi.default/extensions/[email protected]
-rw-rw-r-- myusername/domain users 219319 2019-04-02 18:12 oldcomputer/6gu4hryi.default/extensions/{3ed8cc52-86fc-4613-9026-c1ef969da4c3}.xpi
-rw-rw-r-- myusername/domain users 919233 2019-03-29 19:00 oldcomputer/6gu4hryi.default/extensions/{9ed238c0-af95-11e0-9f1c-0800200c9a66}.xpi
-rw-rw-r-- myusername/domain users 4419959 2020-01-30 13:46 oldcomputer/6gu4hryi.default/extensions/{e2fda1a4-762b-4020-b5ad-a41df1933103}.xpi
drwxrwsr-x myusername/domain users 0 2020-02-14 18:41 oldcomputer/6gu4hryi.default/gmp/
drwxrwsr-x myusername/domain users 0 2017-05-22 12:15 oldcomputer/6gu4hryi.default/gmp/WINNT_x86-msvc/
drwxrwsr-x myusername/domain users 0 2020-02-14 18:43 oldcomputer/6gu4hryi.default/ImapMail/
-rw-rw-r-- myusername/domain users 1306 2016-10-20 14:38 oldcomputer/6gu4hryi.default/ImapMail/imap.gmail.com.msf
如果不熟悉 unix,第一列会告诉它是目录(以 d 开头)还是文件(以 - 而不是 d),然后是不同级别的读/写/执行,接下来是用户名/域,然后是组,然后是文件大小(以字节为单位),然后是日期时间,最后是文件名或目录名。
我最关心的是获取显示日期/时间、大小和文件或目录完整路径的输出。如果可能的话,用户和权限等附加数据会更好。
我尝试使用 CMD 复制此文件dir
,可以使用它获取完整路径列表dir /s /b /ON
,但它不包含日期/时间大小。我也尝试过dir /s /n /ON
它确实给出了日期/时间大小,但它只给出了文件名而没有路径。
我不知道除了编写脚本来拼凑东西之外还能做什么,但我的技能不太好。有人能提供建议吗?
编辑
不幸的是,由于声誉值未超过 15,我无法为 harrymc 点赞。我使用了该答案,但必须添加 -Autosize 才能显示所有数据。这是修改后的解决方案。
powershell "Get-ChildItem -Recurse -Attributes !Directory | select-object Mode, @{N=\"Owner\";E={ (Get-Acl $_.FullName).Owner }}, Length, LastWriteTime, FullName | Format-Table -AutoSize"
EDIT2 我以为它正在工作,但它仍然使用 Format-Table -Autosize 截断,所以我尝试了 Export-csv 路线,它似乎工作正常,没有问题。这是修改后的解决方案:
powershell "Get-ChildItem -Recurse -Attributes !Directory 198798/198798-oa-211013-dsf-00-CLD | select-object Mode, @{N=\"Owner\";E={ (Get-Acl $_.FullName).Owner }}, Length, LastWriteTime, FullName | Export-Csv -Path z:\tmp\test.csv -NoTypeInformation"
答案1
这个 PowerShell 命令非常接近您的目标:
Get-ChildItem -Attributes !Directory | select-object Mode, @{N="Owner";E={ (Get-Acl $_.FullName).Owner }}, Length, LastWriteTime, FullName | Format-Table
要从命令提示符(CMD)执行它,请使用以下命令:
powershell "Get-ChildItem -Attributes !Directory | select-object Mode, @{N=\"Owner\";E={ (Get-Acl $_.FullName).Owner }}, Length, LastWriteTime, FullName | Format-Table"