User Tools

Site Tools


linux:bash

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:bash [2026/05/15 11:36] – [ENVIRONMENT VARIABLEs] v1ctorlinux:bash [2026/05/15 13:30] (current) – [REDIRECTS vs PIPES] v1ctor
Line 59: Line 59:
 export STUFF=blah export STUFF=blah
 </code> </code>
 +
 +To make env variable permanent, you need to store it in a file. Which file - depends on the Shell type:
  
 Type of Shells: Type of Shells:
  
-^ Shell Type ^ When it starts ^ Example ^ +^ Shell Type ^ When it starts ^ Example ^ Reads file 
-| Login Shell | You authenticate (SSH, TTY login, su -, bash -l) | SSH into a server | +| Login Shell | You authenticate (SSH, TTY login, su -, bash -l) | SSH into a server | ~/.profile 
-| Interactive non-login | You open a new terminal in an existing session | New tab in your terminal emulator |+| Interactive non-login | You open a new terminal in an existing session | New tab in your terminal  emulator | ~/.bashrc | 
 + 
 +  * **~/.profile** — runs once per login session. Good for: 
 +    * export PATH=..., export EDITOR=vim 
 +  * **~/.bashrc** — runs every time you open a new interactive bash shell. Good for: 
 +    * aliases, shell functions, prompt 
 + 
 + 
 +==== REDIRECTS vs PIPES ==== 
 + 
 +The core difference: redirects connect a stream to a file (a redirect always has a file on one side). Pipes connect one process to another process. 
 + 
 + 
 +Pipes: process → process: 
 +<code bash> 
 +cmd1 | cmd2           # Takes cmd1's stdout and feeds it directly into cmd2's stdin. No file involved 
 +ls | grep ".txt"      # ls output becomes grep's input 
 +</code> 
 +==== STANDARD INPUT and OUTPUT ==== 
 + 
 +Unix programs have 1 input and 2 outputs. 
 + 
 +When you run a command from a terminal, they all go to/from the terminal by default, e.g.: 
 +<code bash> 
 +$ cat 
 +hello   # Stdin is connected to the terminal, you can type there. 
 +hello   # Stdout - cat prints it right away after you pressed enter. 
 +</code> 
 + 
 + 
 +** < redirects Stdin** 
 +<code bash> 
 +cat < foo.txt 
 +bar 
 +</code>
linux/bash.1778844974.txt.gz · Last modified: by v1ctor