User Tools

Site Tools


myhelp:bash

Differences

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

Link to this comparison view

Next revision
Previous revision
myhelp:bash [2024/03/07 12:12] – created - external edit 127.0.0.1myhelp:bash [2026/04/22 11:48] (current) ulrich
Line 1: Line 1:
-Read a file per line+====== Read a file per line ======
  
-```+<code>
 # while read line; do echo "$line"; done < file.txt # while read line; do echo "$line"; done < file.txt
-```+</code>
  
-Upper to Lower+====== Upper to Lower ======
  
 Is pretty easy done Is pretty easy done
  
-```+<code>
 # cat /path/to/file.txt|tr '[:upper:]' '[:lower:]' # cat /path/to/file.txt|tr '[:upper:]' '[:lower:]'
-```+</code>
  
 or or
  
-```+<code>
 # echo "LadiDA"|tr '[:upper:]' '[:lower:]' # echo "LadiDA"|tr '[:upper:]' '[:lower:]'
-```+</code>
  
-SED Examples+====== SED Examples ======
  
 Delete a line with a string in it. For example old ssh-keys: Delete a line with a string in it. For example old ssh-keys:
  
-```+<code>
 # sed -i "/myuser@old.laptop/d"  .ssh/authorized_keys # sed -i "/myuser@old.laptop/d"  .ssh/authorized_keys
-```+</code>
  
-Calculate+====== Calculate ======
  
 You can use the expr You can use the expr
  
-```+<code>
 # expr 1 + 2 # expr 1 + 2
-```+</code>
  
 and you will get 3 as result. and you will get 3 as result.
Line 39: Line 39:
 Also some more fancy stuff is possible. For example in a for-loop: Also some more fancy stuff is possible. For example in a for-loop:
  
-```+<code>
 for i in {1..9}; do echo "10.20.30.$(expr $i + 40)   servername-$i"; done for i in {1..9}; do echo "10.20.30.$(expr $i + 40)   servername-$i"; done
-```+</code>
  
-Bash redirection+====== Bash redirection ======
  
 stdout to file stdout to file
  
-```+<code>
 # command > file.txt # command > file.txt
-```+</code>
  
 stderr to file  stderr to file 
  
-```+<code>
 # command 2> /dev/null # command 2> /dev/null
-```+</code>
  
 stdout AND stderr to file stdout AND stderr to file
  
-```+<code>
 # command &> file.txt # command &> file.txt
-```+</code>
  
 stdout to file AND stderr to file  stdout to file AND stderr to file 
  
-```+<code>
 # command > file.txt 2> /dev/null # command > file.txt 2> /dev/null
-```+</code>
  
 stdout to stderr stdout to stderr
  
-```+<code>
 # command 1>&2 # command 1>&2
-```+</code>
  
 stderr to stdout stderr to stdout
  
-```+<code>
 # command 2>&1 # command 2>&1
-```+</code>
  
  
myhelp/bash.1709813569.txt.gz · Last modified: by 127.0.0.1 · Currently locked by: 216.73.216.196