Like: printing all but one column somewhere in the middle. It turns into long, long commands that really pull away from the spirit of fast fabrication unix experimentation.
jq and sql both have the same problem :)
Like: printing all but one column somewhere in the middle. It turns into long, long commands that really pull away from the spirit of fast fabrication unix experimentation.
jq and sql both have the same problem :)
$ echo "one two three four five" | awk '{$3="";print}'
one two four five sed 's/ / /g' awk '{$1=$1};1' '{$1=$1}1{print}'
Or the same as '{$1=$1}{print}'
Since the default condition is true. But 1 is shorter than {print}. echo "one two three four five" | awk '{$3="\b"; print}'
Inserts the backspace character (^H), which you can then remove with [global] substitution: awk '{$3="\b"; sub(/\32\b/, ""); print}'
You can, of course, use an arbitrary sentinel value for the field to be deleted. Should work in gawk and BWK awk.Whence perl.
Within infrastructures where perl is installed on 95% of hosts, that 5% really bites you in the ass and leads to infrastructure rot very quickly. You're kinda stuck writing and maintaining two separate scripts to do the same thing.
With Perl, I find that a base installation is almost always available, but many packages might not be.
(Once had a coworker reject a PR I wrote because I included a bash builtin in a deployment script. He said that python is more likely to be installed than bash, so we should not use bash. These debates are funny sometimes.)
The following command is handy for grepping the output:
cat mydata.json | json_pp cut -d " " -f1-2,4-5 file.txt
where file.txt is: one two three four five
and the return is: one two four fiveThat's why I use Perl instead (besides some short one liners in awk, which in some cases are even shorter than the Perl version) and do my JSON parsing in Perl.
This
diff -rs a/ b/ | ask '/identical/ {print $4}' | xargs rm
is one of my often used awk one liners. Unless some filenames contain e.g. whitespace, then it's Perl again
And I use this "historic" one liner only when I know about the contents of both directories. As soon as I need a "safer" solution I use a Perl script and pattern matching, as I said.
diff -rs a/ b/ | perl -ane '/identical$/ && unlink $F[3]'