在本文中,我们将给您介绍关于BashShell;读命令;在Windows7上使用Cygwin的详细内容,并且为您解答win10bashshell的相关问题,此外,我们还将为您提供关于bash–Powe
在本文中,我们将给您介绍关于Bash Shell;读命令;在Windows 7上使用Cygwin的详细内容,并且为您解答win10 bash shell的相关问题,此外,我们还将为您提供关于bash – Powershell比cygwin / unix-shell更具优势、bash – 为什么Cygwin很慢地执行shell命令?、bash – 从Windows桌面的cygwin ssh快捷方式、bash – 使用Cygwin后无法删除Windows 7中网络驱动器中的文件夹的知识。
本文目录一览:- Bash Shell;读命令;在Windows 7上使用Cygwin(win10 bash shell)
- bash – Powershell比cygwin / unix-shell更具优势
- bash – 为什么Cygwin很慢地执行shell命令?
- bash – 从Windows桌面的cygwin ssh快捷方式
- bash – 使用Cygwin后无法删除Windows 7中网络驱动器中的文件夹
Bash Shell;读命令;在Windows 7上使用Cygwin(win10 bash shell)
所以我尝试了这个:
#!/bin/bash echo -e "Enter your name and press [ENTER]: \c" read var_name echo "Your name is: $var_name"
然后我将运行它并输入var_name的名称.
我明白了:
$./project1.sh Enter your name and press [ENTER]: Jake ': not a valid identifierad: `var_name Your name is:
据我所知,我遇到了阅读问题.我正在尝试为我的课程开展一个项目,但我似乎无法弄清楚为什么它不会读它.我毫不夸张地跟着这本书,然后在网上使用这些似乎对我不起作用的例子.有没有人知道这是我的设置还是我错过了什么,谢谢.
我建议这是因为该行:
': not a valid identifierad: `var_name
看起来像两条线一样可疑:
.........................ad: `var_name ': not a valid identifier
合并在一起(.字符表示已被覆盖的内容).
如果你在该行中的变量是var_namecarriage-return而不是更正常的var_name,那就是这种情况.
事实上它是Cygwin也指出了这个结论,因为当你使用Windows编辑器编辑你的脚本时经常遇到麻烦,这个编辑器使用CR / LF,其中Cygwin只需要LF.
我怀疑你会发现在你的实际脚本上做一个od -xcb表明你在一个或多个脚本行上有那些Windows行结尾.
事实上,我刚刚在Ubuntu下通过在读取行的末尾放置一个CTRL-M并输出(稍微修改以显示CTRL-M)来测试它:
pax@pax-desktop:~$od -xcb qq.sh ; ./qq.sh 0000000 2123 622f 6e69 622f 7361 0a68 6365 6f68 # ! / b i n / b a s h \n e c h o 043 041 057 142 151 156 057 142 141 163 150 012 145 143 150 157 0000020 2d20 2065 4522 746e 7265 7920 756f 2072 - e " E n t e r y o u r 040 055 145 040 042 105 156 164 145 162 040 171 157 165 162 040 0000040 616e 656d 6120 646e 7020 6572 7373 5b20 n a m e a n d p r e s s [ 156 141 155 145 040 141 156 144 040 160 162 145 163 163 040 133 0000060 4e45 4554 5d52 203a 635c 2022 720a 6165 E N T E R ] : \ c " \n r e a 105 116 124 105 122 135 072 040 134 143 042 040 012 162 145 141 0000100 2064 6176 5f72 616e 656d 0a0d 6365 6f68 d v a r _ n a m e \r \n e c h o ^^ 144 040 166 141 162 137 156 141 155 145 015 012 145 143 150 157 0000120 2220 6f59 7275 6e20 6d61 2065 7369 203a " Y o u r n a m e i s : 040 042 131 157 165 162 040 156 141 155 145 040 151 163 072 040 0000140 7624 7261 6e5f 6d61 2265 0a0a $ v a r _ n a m e " \n \n 044 166 141 162 137 156 141 155 145 042 012 012 0000154 Enter your name and press [ENTER]: pax ': not a valid identifierar_name Your name is:
换句话说,与您所看到的非常相似.
顺便说一句(现在我可以访问我的Cygwin环境),你看到的是输出:
abcdefghij.sh: line 99 read: `var_name `: not a valid identifier
第二行覆盖第一行,给出:
`: not a valid identifierad: `var_name
换句话说,奇怪的单词identifyierad实际上由标识符和最终广告组成:来自:之所以与上面的例子相似(而不是精确)是因为你的文件名和行号与我的小测试脚本不同.
bash – Powershell比cygwin / unix-shell更具优势
https://stackoverflow.com/questions/573623/#573861
bash – 为什么Cygwin很慢地执行shell命令?
while true; do bash -c "echo hello"; done
你会发现Cygwin的bash缓慢多少.有人知道为什么吗
这是在win7上安装的cygwin 1.7.
感谢Jared的测试思路,我修改了命令(添加bash -c):
time for i in {1..10} ; do bash -c "echo Hello" ; done Hello ... real 0m7.711s //it's the problem user 0m0.091s sys 0m0.476s
bash – 从Windows桌面的cygwin ssh快捷方式
我喜欢Cygwin对Putty这样做.
无论如何 – 打开我很酷的Mintty窗口,然后输入以下命令的过程需要太长时间.
PS – 我正在对这些服务器使用“密钥”身份验证.
首先,我从Windows桌面双击Cygwin Terminal快捷方式.
然后一旦终端会话启动,从命令提示符输入以下内容 –
$eval `ssh-agent` $ssh-add $ssh <username>@<servername>
请记住,我的’servername’是可变的.其实我有大约10个不同的服务器名称可能会被插入到那里 – 因此我需要10个不同的快捷方式.我更喜欢双击我的桌面上的东西,这将启动我的Mintty,并自动执行上述bash shell命令.
有人有或可以推荐一个漂亮/优雅的解决方案来做到这一点吗?
(我有一种感觉,它与我点击的Windows快捷方式图标的Target属性有关.)
C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -
将其替换为以下内容(替换为< username>和< servername>相关):
C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico /bin/bash -l -c "eval `ssh-agent` ; ssh-add ; ssh <username>@<servername>"
根据需要重复其他服务器.而已!
(详细信息:我们用显式调用bash替换参数[这意味着使用标准登录shell]来运行命令-l部分意味着使用登录shell,特别是您的PATH变量设置所以bash可以找到ssh.-c部分只是介绍你应该从你的问题中识别的命令.)
bash – 使用Cygwin后无法删除Windows 7中网络驱动器中的文件夹
我强迫Vim编写文件,但退出文件后,Windows资源管理器或任何Unix shell都没有.然后我尝试重命名保存文件的文件夹(包括 – > IncludesOld),创建一个包含原始名称的新文件夹,并将所有文件移动到新文件夹.这使原始文件夹(IncludesOld)为空,但我无法将其删除.如果我尝试删除它,则不会显示任何错误消息,但该文件夹仍然存在.
我猜这与Cygwin保持自己的文件系统视图有关,这与我看到的不一致,但我不知道该怎么办.
运行mount会产生以下输出:
C:/cygwin64/bin on /usr/bin type ntfs (binary,auto) C:/cygwin64/lib on /usr/lib type ntfs (binary,auto) C:/cygwin64 on / type ntfs (binary,auto) B: on /cygdrive/b type udf (binary,noacl,posix=0,user,noumount,auto) C: on /cygdrive/c type ntfs (binary,auto) D: on /cygdrive/d type ntfs (binary,auto) E: on /cygdrive/e type ntfs (binary,auto) O: on /cygdrive/o type ntfs (binary,auto) S: on /cygdrive/s type ntfs (binary,auto) T: on /cygdrive/t type ntfs (binary,auto) U: on /cygdrive/u type ntfs (binary,auto) W: on /cygdrive/w type ntfs (binary,auto) X: on /cygdrive/x type ntfs (binary,auto)
有问题的文件夹在W:驱动器上,但运行umount / cygdrive / w给我umount:/ cygdrive / w:无效的参数,我只是猜测这是我应该尝试做的事情.
解决方法
关于Bash Shell;读命令;在Windows 7上使用Cygwin和win10 bash shell的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于bash – Powershell比cygwin / unix-shell更具优势、bash – 为什么Cygwin很慢地执行shell命令?、bash – 从Windows桌面的cygwin ssh快捷方式、bash – 使用Cygwin后无法删除Windows 7中网络驱动器中的文件夹等相关知识的信息别忘了在本站进行查找喔。
本文标签: