New answers tagged

0

To compare $0 with one value use == and not =. = assigns new value to $0. If you assign a new value the expression $0=2393 (e.g.) is evaluated as true by awk and then awk prints 9.


0

perl -pi -e 's/(^[^,]*,\d)\d+,/$1,/g' list.csv Binned by first digit.


3

You don't have copy them one by one, you can paste all the lines together and newlines will work as Enter. The reason that ( var1="myvar1" var2="myvar2" ) doesn't work is that because it's executed in a subshell. It would work if you printed contents of the variable before the final ): ( var1="myvar1" var2="myvar2" echo $var2 ) It's explained in ...


0

The parenthesis you used causes the enclosed commands to be executed by a subshell; hence once that shell exits, de variables are still not set in the current shell. I'm at a loss why you think those parenthesis would set those variables "in one go", or why it would be necessary to them them "in one go"; however you could place those assignments on one line ...


4

A single - generally means either standard input or standard output: standard input if it’s used in a context where the input is specified (as in your zip example), standard output in a context where the output is specified (as in your wget example). It’s used as a special filename, with options which accept filenames; thus it only has a special meaning if ...


1

The problem here seems to be with the single-quotes in $DATEJ. Your variable imposes them. Change that to DATEJ=`echo -n "2012-03-02 22:00"` and in the final command: date -d "$DATEJ EDT" +%s This will work: $ date -d '2012-03-02 22:00 EDT' +%s 1330740000 $ DATEJ=`echo -n "2012-03-02 22:00"` $ echo $DATEJ 2012-03-02 22:00 $ date -d "$DATEJ EDT" +%s ...


6

The backslashes do nothing. The - and + characters do not need to be escaped, because they are not special in any way in the syntax of any shell. $ set -o xtrace $ date +%F-%T + date +%F-%T 2019-08-15-11:51:46 $ date \+%F\-%T + date +%F-%T 2019-08-15-11:51:50 As you can see in the above trace output, the command that gets executed by the shell is the ...


Top 50 recent answers are included