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:misc [2025/11/19 23:21] – [awk] tmadelinux:misc [2026/06/12 11:07] (current) – [Set variable] tmade
Line 35: Line 35:
 } }
 </code> </code>
 +
 +====yq====
 +yq - commandline YAML processor, to visualize yaml output in a readable way
 +
 +Example to replace a openshift-route with yq:
 +
 +  oc get route/${route} -o yaml | yq eval '.spec.tls.certificate = strenv(TLSCERT) | .spec.tls.key = strenv(TLSKEY)' - | oc replace -f -
  
 ====Manipulating Strings==== ====Manipulating Strings====
Line 76: Line 83:
 Foo Foo
 </code> </code>
 +
 +====Set variable====
 +Alternative to "sed":
 +
 +  var="oldvalue"
 +  var="${var/oldvalue/newvalue}"
 +  echo $var
 +  newvalue
 +
  
 ====awk==== ====awk====
Line 88: Line 104:
   ifconfig -a | awk '/inet 10/{print $2}'                                                                        #getting IP adress starting with "inet 10"   ifconfig -a | awk '/inet 10/{print $2}'                                                                        #getting IP adress starting with "inet 10"
   echo "somestring1 somestring2" | awk '{print $1,$2}'   echo "somestring1 somestring2" | awk '{print $1,$2}'
-  awk '{print $3 "\t" $4}' test.txt+  awk -F ':' '{print $1 "\t" $4}' /etc/passwd                                                                    #print all username + uid
   awk 'length($0) > 18' marks.txt                                                                                #print only those lines that contain more than 18 characters   awk 'length($0) > 18' marks.txt                                                                                #print only those lines that contain more than 18 characters
linux/misc.1763590886.txt.gz · Last modified: by tmade
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki