vps交流

【已解决】遇到一个不明白的Linux问题,有没有大佬……


本帖最后由 shc 于 2021-12-6 12:12 编辑

这样一条命令:

  1. apt-add-repository -s -y ‘deb http://archive.ubuntu.com/ubuntu/ ‘$OS’ main restricted’

复制代码

这里OS的值是focal

然后,我在Shell里面直接执行,结果如下:

  1. Hit:1 http://asi-fs-l.contabo.net/ubuntu focal InRelease
  2. Get:2 http://asi-fs-l.contabo.net/ubuntu focal-updates InRelease [114 kB]
  3. Get:3 http://asi-fs-l.contabo.net/ubuntu focal-backports InRelease [108 kB]
  4. Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
  5. Get:5 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
  6. Get:6 http://archive.ubuntu.com/ubuntu focal/main Sources [847 kB]
  7. Get:7 http://archive.ubuntu.com/ubuntu focal/restricted Sources [6,472 B]
  8. Get:8 http://archive.ubuntu.com/ubuntu focal/main i386 Packages [718 kB]
  9. Get:9 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [970 kB]
  10. Get:10 http://archive.ubuntu.com/ubuntu focal/main Translation-en [506 kB]
  11. Get:11 http://archive.ubuntu.com/ubuntu focal/main amd64 c-n-f Metadata [29.5 kB]
  12. Get:12 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [22.0 kB]
  13. Get:13 http://archive.ubuntu.com/ubuntu focal/restricted i386 Packages [8,112 B]
  14. Get:14 http://archive.ubuntu.com/ubuntu focal/restricted Translation-en [6,212 B]
  15. Get:15 http://archive.ubuntu.com/ubuntu focal/restricted amd64 c-n-f Metadata [392 B]
  16. Fetched 3,714 kB in 2s (2,213 kB/s)

复制代码

如果我放在.sh文件里面执行,结果如下:

  1. Hit:1 http://asi-fs-l.contabo.net/ubuntu focal InRelease
  2. Get:2 http://asi-fs-l.contabo.net/ubuntu focal-updates InRelease [114 kB]
  3. Get:3 http://asi-fs-l.contabo.net/ubuntu focal-backports InRelease [108 kB]
  4. Get:4 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
  5. Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
  6. Get:6 http://archive.ubuntu.com/ubuntu bionic/main Sources [829 kB]
  7. Get:7 http://archive.ubuntu.com/ubuntu bionic/restricted Sources [5,324 B]
  8. Get:8 http://archive.ubuntu.com/ubuntu bionic/main i386 Packages [1,007 kB]
  9. Get:9 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1,019 kB]
  10. Get:10 http://archive.ubuntu.com/ubuntu bionic/main Translation-en [516 kB]
  11. Get:11 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [9,184 B]
  12. Get:12 http://archive.ubuntu.com/ubuntu bionic/restricted i386 Packages [9,156 B]
  13. Get:13 http://archive.ubuntu.com/ubuntu bionic/restricted Translation-en [3,584 B]
  14. Fetched 3,977 kB in 2s (2,254 kB/s)

复制代码

为啥结果会不一样呢?研究了一个小时了,也没想明白原因……求大佬解答……

感谢【已解决】遇到一个不明白的Linux问题,有没有大佬……

脚本里直接把变量换成字符串 focal 也这样吗?
echo ‘deb http://archive.ubuntu.com/ubuntu/ ‘$OS’ main restricted’
本帖最后由 shc 于 2021-12-6 12:13 编辑

G.K.D 发表于 2021-12-6 12:07
脚本里直接把变量换成字符串 focal 也这样吗?

我傻了,谢谢大佬

tcpdump 发表于 2021-12-6 12:08
echo ‘deb http://archive.ubuntu.com/ubuntu/ ‘$OS’ main restricted’

我傻了,谢谢大佬【已解决】遇到一个不明白的Linux问题,有没有大佬……