$ echo "a b c" | awk 'BEGIN {OFS=","}; {print $0};' - a b c
I tried to see if applied OFSafter the last field, so expecting the output to be either
OFS
a,b,c
or
a,b,c,
but the change OFSdoes not work. Why?
You must change / set the field so that it $0will be recounted, then it will be applied OFS. For example.
$0
echo "a b c" | awk 'BEGIN {OFS=","}; {$1=$1;print $0};'
$ 0 does not change, assigning OFS. However, $ 0 changes when assigned to any of its elements, including any non-existent fields.
echo "ab c" | awk 'BEGIN {OFS = ","}; {$ 4 = ""; print $ 0}; -
gives: a, b, c,
Source: https://habr.com/ru/post/1623492/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1623487/assign-colors-to-each-level-of-factors-in-r-figures&usg=ALkJrhhOEe6wX5OsRGdiOFrnKXURspgIhgCommon x axis in Pandas Python - pythontvOS button button background color where it is not installed correctly - colorsConverting String to Android JSONObject loses utf-8 - jsonThe footer rises when the keyboard is displayed - androidWhat is the dominant term in 2 ^ n or n ^ 2 for the big record O - big-oHow to send image using custom iOS keyboard - iosПреобразуйте org.apache.spark.mllib.linalg.Vector RDD в DataFrame в Spark, используя Scala - scalaGoogle Maps iOS URL URL not working? - iosSequence of elements, but "connection unavailable: raise joinWithSeparator () error" - swift-playgroundAll Articles