Bash 用于创建符号链接的脚本正在我的变量中添加字符 ._ 以创建符号链接
Bash script to create a symlink is adding the characters ._ in my variable to create a symlink
我正在使用下面的 bash 脚本随机选择一个 .mp4 文件并将其符号链接到应用程序 (Plex) 可以读取的另一个文件夹。问题是似乎(随机地)在变量 $FILE 中添加了一个“._”,然后在符号链接中使用它。有什么想法吗?
脚本
#/bin/sh
rm -f /media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ/preroll.mp4
find /media/joshua/Media/PlexPrerolls/ -maxdepth 1 -not -type d | sort -R | tail -1 | while read FILE; do
ln -s "$FILE" /media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ/preroll.mp4 ;
done
符号链接检查
只看每 4 行的末尾。
请参阅 ._PlexStrangerThingsPreroll.mp4
,然后再参阅 ._PlexSnowPreroll.mp4
._Plex preroll 6F.mp4
._ 不应该出现在那里。
lrwxrwxrwx 1 root root 64 Apr 10 13:19 preroll.mp4 -> /media/joshua/Media/PlexPrerolls/._PlexStrangerThingsPreroll.mp4
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 0
lrwxrwxrwx 1 root root 54 Apr 10 13:23 preroll.mp4 -> /media/joshua/Media/PlexPrerolls/._PlexSnowPreroll.mp4
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 0
lrwxrwxrwx 1 root root 52 Apr 10 13:24 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/Plex preroll 8F.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 4.0K
lrwxrwxrwx 1 root root 66 Apr 10 13:24 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/Plex Preroll-Fallout4-1080-12.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 0
lrwxrwxrwx 1 root root 52 Apr 10 13:25 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/Plex preroll 6F.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 4.0K
lrwxrwxrwx 1 root root 63 Apr 10 13:25 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/Plex Preroll energy reveal.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 4.0K
lrwxrwxrwx 1 root root 62 Apr 10 13:26 preroll.mp4 -> /media/joshua/Media/PlexPrerolls/PlexStrangerThingsPreroll.mp4
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 0
lrwxrwxrwx 1 root root 54 Apr 10 13:27 preroll.mp4 -> /media/joshua/Media/PlexPrerolls/._PlexFirePreroll.mp4
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 0
lrwxrwxrwx 1 root root 54 Apr 10 13:27 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/._Plex preroll 6F.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 0
lrwxrwxrwx 1 root root 55 Apr 10 13:28 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/._Plex preroll 13E.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 4.0K
lrwxrwxrwx 1 root root 63 Apr 10 13:28 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/Plex Preroll energy reveal.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 4.0K
lrwxrwxrwx 1 root root 63 Apr 10 13:28 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/Plex Preroll energy reveal.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 4.0K
lrwxrwxrwx 1 root root 68 Apr 10 13:46 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/._Plex Preroll-Fallout4-1080-12.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 0
lrwxrwxrwx 1 root root 54 Apr 10 13:50 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/._Plex preroll 6F.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 4.0K
lrwxrwxrwx 1 root root 68 Apr 10 13:50 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/._Plex Preroll-Fallout4-1080-12.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 4.0K
lrwxrwxrwx 1 root root 68 Apr 10 13:50 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/._Plex Preroll-Fallout4-1080-12.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 0
lrwxrwxrwx 1 root root 52 Apr 10 13:50 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/Plex preroll 8E.mp4'
我正在使用 ubuntu 18
谢谢@JNevill,你是对的。这些文件来自 MacOS 到 Ubuntu。我没有意识到 MacOS 会创建这些隐藏文件。每当我在目录中列出 ls
文件时,它们都不会显示。
当我将 -not \( -iname "._*" \)
添加到脚本时,它会忽略这些文件。
下面是更新后的脚本。
#/bin/sh
rm -f /media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ/preroll.mp4
find /media/joshua/Media/PlexPrerolls/ -maxdepth 1 -not -type d -not \( -iname "._*" \) | sort -R | tail -1 | while read FILE; $
ln -s "$FILE" /media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ/preroll.mp4 ;
done
此外,我忘了在我的原文 post 中说我最初从以下位置获得此脚本:https://www.reddit.com/r/PleX/comments/arccd7/better_way_to_randomize_plexrolls/
如果有人因为搜索引擎或其他原因来到这里,我已经创建了说明来实现此脚本的预期目的:https://www.reddit.com/r/PleX/comments/fyoqh4/randomizing_prerolls_on_linux/
我正在使用下面的 bash 脚本随机选择一个 .mp4 文件并将其符号链接到应用程序 (Plex) 可以读取的另一个文件夹。问题是似乎(随机地)在变量 $FILE 中添加了一个“._”,然后在符号链接中使用它。有什么想法吗?
脚本
#/bin/sh
rm -f /media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ/preroll.mp4
find /media/joshua/Media/PlexPrerolls/ -maxdepth 1 -not -type d | sort -R | tail -1 | while read FILE; do
ln -s "$FILE" /media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ/preroll.mp4 ;
done
符号链接检查
只看每 4 行的末尾。
请参阅 ._PlexStrangerThingsPreroll.mp4
,然后再参阅 ._PlexSnowPreroll.mp4
._Plex preroll 6F.mp4
._ 不应该出现在那里。
lrwxrwxrwx 1 root root 64 Apr 10 13:19 preroll.mp4 -> /media/joshua/Media/PlexPrerolls/._PlexStrangerThingsPreroll.mp4
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 0
lrwxrwxrwx 1 root root 54 Apr 10 13:23 preroll.mp4 -> /media/joshua/Media/PlexPrerolls/._PlexSnowPreroll.mp4
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 0
lrwxrwxrwx 1 root root 52 Apr 10 13:24 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/Plex preroll 8F.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 4.0K
lrwxrwxrwx 1 root root 66 Apr 10 13:24 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/Plex Preroll-Fallout4-1080-12.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 0
lrwxrwxrwx 1 root root 52 Apr 10 13:25 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/Plex preroll 6F.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 4.0K
lrwxrwxrwx 1 root root 63 Apr 10 13:25 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/Plex Preroll energy reveal.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 4.0K
lrwxrwxrwx 1 root root 62 Apr 10 13:26 preroll.mp4 -> /media/joshua/Media/PlexPrerolls/PlexStrangerThingsPreroll.mp4
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 0
lrwxrwxrwx 1 root root 54 Apr 10 13:27 preroll.mp4 -> /media/joshua/Media/PlexPrerolls/._PlexFirePreroll.mp4
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 0
lrwxrwxrwx 1 root root 54 Apr 10 13:27 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/._Plex preroll 6F.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 0
lrwxrwxrwx 1 root root 55 Apr 10 13:28 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/._Plex preroll 13E.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 4.0K
lrwxrwxrwx 1 root root 63 Apr 10 13:28 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/Plex Preroll energy reveal.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 4.0K
lrwxrwxrwx 1 root root 63 Apr 10 13:28 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/Plex Preroll energy reveal.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 4.0K
lrwxrwxrwx 1 root root 68 Apr 10 13:46 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/._Plex Preroll-Fallout4-1080-12.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 0
lrwxrwxrwx 1 root root 54 Apr 10 13:50 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/._Plex preroll 6F.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 4.0K
lrwxrwxrwx 1 root root 68 Apr 10 13:50 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/._Plex Preroll-Fallout4-1080-12.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 4.0K
lrwxrwxrwx 1 root root 68 Apr 10 13:50 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/._Plex Preroll-Fallout4-1080-12.mp4'
root@wyss-server:/media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ# ls -lh
total 0
lrwxrwxrwx 1 root root 52 Apr 10 13:50 preroll.mp4 -> '/media/joshua/Media/PlexPrerolls/Plex preroll 8E.mp4'
我正在使用 ubuntu 18
谢谢@JNevill,你是对的。这些文件来自 MacOS 到 Ubuntu。我没有意识到 MacOS 会创建这些隐藏文件。每当我在目录中列出 ls
文件时,它们都不会显示。
当我将 -not \( -iname "._*" \)
添加到脚本时,它会忽略这些文件。
下面是更新后的脚本。
#/bin/sh
rm -f /media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ/preroll.mp4
find /media/joshua/Media/PlexPrerolls/ -maxdepth 1 -not -type d -not \( -iname "._*" \) | sort -R | tail -1 | while read FILE; $
ln -s "$FILE" /media/PATH_TO_PREROLL_THAT_PLEX_CAN_READ/preroll.mp4 ;
done
此外,我忘了在我的原文 post 中说我最初从以下位置获得此脚本:https://www.reddit.com/r/PleX/comments/arccd7/better_way_to_randomize_plexrolls/
如果有人因为搜索引擎或其他原因来到这里,我已经创建了说明来实现此脚本的预期目的:https://www.reddit.com/r/PleX/comments/fyoqh4/randomizing_prerolls_on_linux/