-1

I want to remove all the whitespaces from the ouptut of $date by using $awk but somehow it does not work as intended, what am I missing here?

date | awk '{gsub(/ *\| */,",")}1'

Sat 28 Mar 23:13:22 CET 2020

2 Answers2

1

for this sed might be easier

$ date | sed 's/ //g'

SatMar2819:00:12EDT2020
karakfa
  • 66,216
  • 7
  • 41
  • 56
-1

Solution with the underscore set as the separator:

date | awk '{gsub(/ /,"_")}1'

Workaround without awk(no separator):

date | tr -d '[:space:]'
Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 1
    That awk "solution" doesn't make sense. If you don't want an underscore then don't type an underscore. – Ed Morton Mar 28 '20 at 22:57