bash 如何在 linux-shell 中使用 `amp;` & `gt;` 命令?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23013352/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 10:10:35  来源:igfitidea点击:

how to use `amp;` & `gt;` commands in linux-shell?

linuxbashcommand

提问by user3523781

i downloaded a script from Internet. when i run it, it stops because of &&command and says No command 'amp' found

我从互联网上下载了一个脚本。当我运行它时,它因为&&命令而停止并说No command 'amp' found

what is amp? what is gt? what does they do?

什么是amp?什么是gt?他们做什么?

回答by Brian Agnew

I suspect this has undergone an HTML entity translation. You want to reverse this e.g.

我怀疑这已经过 HTML 实体翻译。你想扭转这个,例如

& becomes &

and

> becomes >

So (for example)

所以(例如)

cd /dir && ls > filename

would become

会成为

cd /dir && ls > filename

回答by Oliver Matthews

&ampand &gtare html escape codes for &and >respectively.

&amp&gt对于HTML转义码&>分别。

Either you have downloaded a script that has been htmlized, or you've accidentally downloaded a webpage with the script on.

要么您下载了一个已被 html 化的脚本,要么您不小心下载了一个带有该脚本的网页。

Check the top line of the file. if it starts with something like #!/usr/bin/bashthen it's the former and you just need to reverse the changes. If it has something like a <html>tag as the start, then you've downloaded the webpage - go back to where you got it and look for something like a 'raw' link

检查文件的第一行。如果它以类似的内容开头,#!/usr/bin/bash则是前者,您只需要撤消更改即可。如果它有一个类似<html>标签的东西作为开始,那么你已经下载了网页 - 回到你得到它的地方并寻找类似“原始”链接的东西

回答by Ling Loeng

in other word, &amp;is the character reference for "An ampersand". While gtis simply we call it as (greater than).

换句话说,&amp;是“一个和号”的字符参考。虽然gt只是我们称之为(大于)。