Comments (1)
补充:
Shell重定向 &>file、2>&1、1>&2 、/dev/null的区别
Shell 重定向是一种将命令的输入或输出重定向到不同位置的技术。下面是几种常见的 Shell 重定向方式及其区别:
-
>
和&>
:>
用于将命令的标准输出重定向到指定文件中,而&>
则将标准输出和标准错误输出合并后重定向到指定文件中。例如,command > file
将命令的标准输出重定向到 file 文件中,而command &> file
则将标准输出和标准错误输出一起重定向到 file 文件中。 -
2>&1
和1>&2
:2>&1
表示将标准错误输出重定向到标准输出,1>&2
表示将标准输出重定向到标准错误输出。这样做的目的是将标准错误输出和标准输出合并为一个流,方便统一处理。例如,command 2>&1
将标准错误输出重定向到标准输出上。 -
/dev/null
:/dev/null
是一个特殊的文件,也被称为黑洞文件,它可以将所有重定向到它的输入都丢弃掉。可以将其用于不需要关心命令的输出或错误输出的情况。例如,command > /dev/null
将命令的标准输出丢弃掉,而command 2> /dev/null
则将命令的标准错误输出丢弃掉。
总结:
>
用于将标准输出重定向到文件。&>
用于将标准输出和标准错误输出合并后重定向到文件。2>&1
将标准错误输出重定向到标准输出。1>&2
将标准输出重定向到标准错误输出。/dev/null
是一个特殊文件,用于丢弃输入,可以用于丢弃标准输出或标准错误输出。
from node-index.
Related Issues (20)
- 断言库chai
- 数据库MySql基础
- [shell] 入门 - 1 基础
- [shell] 入门 - 2 运算符
- [shell] 入门 - 3 字符串和数组
- [shell] 入门 - 4 条件控制
- [shell] 入门 - 5 函数
- [vim] 入门基础
- git 常用命令汇总 HOT 1
- [docker] 入门 - 01 docker环境搭建
- [docker] 入门 - 02 Docker容器与镜像
- [docker] 入门 - 03 docker网络
- [docker] 入门 - 04 docker的持久化存储与数据共享
- [docker] 入门 - 05 Docker Compose 多容器部署
- [docker] 入门 - 06 Swarm
- 好用的库与框架推荐
- 性能分析
- TypeScript 内置的类型方法和工具类型
- 100万个函数执行保证浏览器不卡
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-index.