Autosave: 2022-12-11 14:30:05
This commit is contained in:
		
							parent
							
								
									aa90d1ff79
								
							
						
					
					
						commit
						c5c30ab3d4
					
				
					 2 changed files with 30 additions and 1 deletions
				
			
		| 
						 | 
					@ -47,6 +47,6 @@ The [mode](/Programming_Languages/Shell_Scripting/File_permissions_and_execution
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## /dev/null
 | 
					## /dev/null
 | 
				
			||||||
 | 
					
 | 
				
			||||||
`/dev/null` is a virtual device: it doesn't actually exist as a piece of hardware on the system.
 | 
					`/dev/null` is a virtual device: it doesn't actually exist as a piece of hardware on the system. It can be useful when [bash scripting](/Programming_Languages/Shell/Redirect_to_dev_null.md) as a place to direct output that you don't care about, for example errors or verbose program read-outs.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
> ! Make notes on this. Base on : https://linuxhint.com/what_is_dev_null/
 | 
					> ! Make notes on this. Base on : https://linuxhint.com/what_is_dev_null/
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										29
									
								
								Programming_Languages/Shell/Redirect_to_dev_null.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								Programming_Languages/Shell/Redirect_to_dev_null.md
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,29 @@
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					categories:
 | 
				
			||||||
 | 
					  - Programming Languages
 | 
				
			||||||
 | 
					tags:
 | 
				
			||||||
 | 
					  - shell
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Redirecting to `/dev/null`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					You'll see the following a lot when reading shell scripts:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					[some_command] > /dev/null 2>&1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					This is a redirection statement. It is redirecting data to the `null` device on Unix systems. Basically to a black hole or shredder where you can't access it because you don't want it to be output to stout.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The `2>&1` argument is the content: any errors that the program may generate and try to show in stout.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Example
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					I have used this in my Mongo start-up script:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					mongodb-compass > /dev/null 2>&1
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Here, I just want the MongoDB Compass application to start, I don't care if it wants to output complaints to the stout.
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue