Mac Finder中显示和隐藏文件的方法
按照以下步骤查看Mac上Finder中的隐藏文件。
打开Finder窗口
现在在左栏中,点击 "设备 "下的Mac名称。
选择并点击启动驱动器。默认情况下,它读作Macintosh HD。
接下来,按Command Shift .(句号)键。现在你将能够看到几个带有""的文件。
要再次隐藏它们,按住Command Shift . (句号)。
方法1:
重命名文件夹前面加“.”
➜ Downloads pwd
/Users/lex/Downloads/AirDrop
➜ AirDrop mkdir hidden
➜ AirDrop cd hidden
➜ hidden seq 1 5|while read line;do touch $line;done
➜ hidden ls -al
total 0
drwxr-xr-x 7 lex staff 224 Sep 28 09:09 .
drwx------ 39 lex staff 1248 Sep 28 09:07 ..
-rw-r--r-- 1 lex staff 0 Sep 28 09:09 1
-rw-r--r-- 1 lex staff 0 Sep 28 09:09 2
-rw-r--r-- 1 lex staff 0 Sep 28 09:09 3
-rw-r--r-- 1 lex staff 0 Sep 28 09:09 4
-rw-r--r-- 1 lex staff 0 Sep 28 09:09 5
➜ hidden cd ..
➜ AirDrop mv hidden .hidden
重命名隐藏文件
查看效果 默认就是隐藏的了 。如果需要展示出来可以直接
shitf ommand .
方法2:在Mac上用终端命令解除隐藏文件。
我们在Mac中利用终端、命令行界面。轻松的显示隐藏的文件和隐藏文件。与Finder不同,在Finder中,你需要遵循一系列复杂的指令,而使用Terminal命令则非常简单。
启动终端
这里,复制粘贴以下命令
defaults write com.apple.Finder AppleShowAllFiles true
killall Finder
注意:
参数True会显示隐藏的文件,而当你把它改为false时,它会再次隐藏文件
当然所有的这些操作都逃不过ls -al的眼睛
参数True会显示隐藏的文件,可以直接查看Finder
➜ AirDrop defaults write com.apple.Finder AppleShowAllFiles true
➜ AirDrop killall Finder
➜ AirDrop ls -al|grep ^d
drwxr-xr-x 29 lex staff 928 Sep 28 09:12 .
drwx------ 38 lex staff 1216 Sep 28 09:10 ..
drwxr-xr-x 7 lex staff 224 Sep 28 09:09 .hidden
drwxr-xr-x 3 lex staff 96 Sep 21 21:11 156888209236695
drwxr-xr-x 74 lex staff 2368 Sep 26 12:49 NCE 1 audio
drwx------ 11 lex staff 352 Sep 26 08:53 充电提示音素材
改为false时,它会再次隐藏文件
➜ AirDrop defaults write com.apple.Finder AppleShowAllFiles false
➜ AirDrop killall Finder
➜ AirDrop ls -al|grep ^d
drwxr-xr-x 29 lex staff 928 Sep 28 09:12 .
drwx------ 38 lex staff 1216 Sep 28 09:10 ..
drwxr-xr-x 7 lex staff 224 Sep 28 09:09 .hidden
drwxr-xr-x 3 lex staff 96 Sep 21 21:11 156888209236695
drwxr-xr-x 74 lex staff 2368 Sep 26 12:49 NCE 1 audio
drwx------ 11 lex staff 352 Sep 26 08:53 充电提示音素材
方法3:
利用命令“chflags hidden” 可以隐藏文件或文件夹。
➜ ScreenShot pwd
/Users/lex/Downloads/ScreenShot
➜ ScreenShot mkdir testdir
➜ ScreenShot mv Screen\ Recording\ 2020-09-2* ./testdir
➜ ScreenShot chflags hidden /Users/lex/Downloads/ScreenShot/testdir
这个时候是到finder中是看不到这个路径了,但是终端下是可以有的
➜ ScreenShot ls
'Sep-28-2020 08-52-34.gif' 'iShot2020-09-26 17.32.06.png' 金玟岐-岁月神偷.mp4
Sep-28.gif testdir
➜ ScreenShot ls testdir/*
'testdir/Screen Recording 2020-09-22 at 9.47.58 AM-Segment 1.mp4'
'testdir/Screen Recording 2020-09-22 at 9.47.58 AM.mov'
'testdir/Screen Recording 2020-09-28 at 8.34.29 AM-Segment 1.mp4'
'testdir/Screen Recording 2020-09-28 at 8.34.29 AM.mov'
显示这个路径
➜ ScreenShot chflags nohidden /Users/lex/Downloads/ScreenShot/testdir
➜ ScreenShot ls
'Sep-28-2020 08-52-34.gif' 'iShot2020-09-26 17.32.06.png' 金玟岐-岁月神偷.mp4
Sep-28.gif testdir
➜ ScreenShot ls testdir/*
'testdir/Screen Recording 2020-09-22 at 9.47.58 AM-Segment 1.mp4'
'testdir/Screen Recording 2020-09-22 at 9.47.58 AM.mov'
'testdir/Screen Recording 2020-09-28 at 8.34.29 AM-Segment 1.mp4'
'testdir/Screen Recording 2020-09-28 at 8.34.29 AM.mov'
再次到finder中路径是正常显示的
,