当前位置:网站首页><, < <,>, > > Introduction in shell
<, < <,>, > > Introduction in shell
2022-07-03 08:51:00 【Xiaoping is extraordinary】
One 、 File descriptor
Linux After starting , It will open by default 3 File descriptors , Namely : The standard input standard input 0; Output correctly standard output 1; Error output :error output 2
Linux Shell The next common input / output operator is :
- The standard input (stdin) : The code is 0 , Use < or << ; /dev/stdin -> /proc/self/fd/0 0 representative :/dev/stdin
- standard output (stdout): The code is 1 , Use > or >> ; /dev/stdout -> /proc/self/fd/1 1 representative :/dev/stdout
- Standard error output (stderr): The code is 2 , Use 2> or 2>> ; /dev/stderr -> /proc/self/fd/2 2 representative :/dev/stderr
Two 、> ,>>
Output redirection : Redirect output to screen or device or file ; among , >> Means to append new information to the file
Turn off correct output and error output :ls test.txt test.txt1 1>&- 2>&-
& Represents all outputs :ls t.txt t.txt1 &>te.txt
&[-,1,2] respectively Close the corresponding identification , Output correctly , Error output
3、 ... and 、<,<<
Input redirection
From file test.txt Get input to cat, then cat Enter redirect to text1.txt:cat > text1.txt < test.txt
<< It means to accept the identification of the end of an input , When you enter this ID, end the input :
cat > t.txt << eof
> q
> a
> z
> eof
# When the console enters eof after , End input
Four 、exec Binding redirection
Bind a new file descriptor 6, And bind standard output ( It is equivalent to saving a temporary copy)
ls /proc/self/fd
0 1 2 3
exec 6>&1
ls /proc/self/fd
0 1 2 3 6
# Bind the standard output back :
exec 1>&6
ls /proc/self/fd
0 1 2 3 6
# Close the custom file descriptor
exec 6>&-
ls /proc/self/fd
0 1 2 3
️ Be careful : If you bind standard output directly to a file , So the problem is , Never come back
边栏推荐
- How to use Jupiter notebook
- Escape from heaven and forget what he suffered. In ancient times, it was called the punishment of escape from heaven. Article collection
- [concurrent programming] concurrent tool class of thread
- UE4 source code reading_ Bone model and animation system_ Animation node
- [public key cryptography] ECC elliptic cryptosystem (implementing ElGamal encryption method)
- Unity learning notes
- Notes and bugs generated during the use of h:i:s and y-m-d
- PHP function date (), y-m-d h:i:s in English case
- [set theory] order relation (total order relation | total order set | total order relation example | quasi order relation | quasi order relation theorem | bifurcation | quasi linear order relation | q
- MySQL three logs
猜你喜欢
Gradle's method of dynamically modifying APK package name
Try to reprint an article about CSDN reprint
Log4j2 vulnerability recurrence and analysis
[concurrent programming] explicit lock and AQS
Final review of Database Principles
PHP uses foreach to get a value in a two-dimensional associative array (with instances)
[RPC] RPC remote procedure call
Unity editor expansion - draw lines
Dealing with duplicate data in Excel with xlwings
[MySQL] MySQL Performance Optimization Practice: introduction of database lock and index search principle
随机推荐
How to place the parameters of the controller in the view after encountering the input textarea tag in the TP framework
How does unity fixedupdate call at a fixed frame rate
UE4 source code reading_ Bone model and animation system_ Animation compression
Analysis of Alibaba canal principle
UE4 source code reading_ Mobile synchronization
[concurrent programming] collaboration between threads
求组合数 AcWing 886. 求组合数 II
22-06-28 Xi'an redis (02) persistence mechanism, entry, transaction control, master-slave replication mechanism
OpenGL learning notes
Deeply understand the underlying data structure of MySQL index
Allocation exception Servlet
[concurrent programming] explicit lock and AQS
UE4 source code reading_ Bone model and animation system_ Animation process
I made mistakes that junior programmers all over the world would make, and I also made mistakes that I shouldn't have made
Mortgage Calculator
Animation_ IK overview
[rust notes] 09- special types and generics
Unity interactive water ripple post-treatment
[concurrent programming] concurrent tool class of thread
Cesium for unreal quick start - simple scenario configuration