grimoire

personal wiki
git clone git://git.pyratebeard.net/grimoire.git
Log | Files | Refs

sed.md (630B)


      1 # sed
      2 
      3 print specific line number from file
      4 ```
      5 sed 'n!d' file
      6 ```
      7 
      8 add character
      9 ```
     10 s/regex/&n/
     11 ```
     12 
     13 convert first word before equals symbol from lower to upper 
     14 _this is used in config files such as ifcfg to convert all variable names_
     15 ```
     16 :%s/^[[:alpha:]_]\{1,\}=/\U&/
     17 ```
     18 
     19 append line after match
     20 ```
     21 sed '/match/a hello friend' filename
     22 ```
     23 
     24 prepend line before match
     25 ```
     26 sed '/match/i hello friend' filename
     27 ```
     28 
     29 {upper,lower}case test
     30 ```
     31 sed 's/[a-z].*=/\U&/' filename
     32 ```
     33 _this example is for uppercasing var names in a rhel network config file_
     34 http://bigdatums.net/2017/09/30/how-to-uppercase-lowercase-text-with-sed/