Tag Info

Hot answers tagged


You don't need to use variable ba, try: $ echo $a | awk -F',' '{print '"$b"'}' 15986327,415532694,875121642 With this, $b is expanded by the shell, not by awk. And the rest of awk statement is not affect, because they're enclosed in single quote.


awk variables are just used for their values, like variables in most languages - they aren't re-parsed for expressions. You can do what you want with this: a='15986327,415532694,850257614,875121642,20140819' echo $a | awk -F, -v OFS=, '{print $1, $2, $4}' (setting OFS so you get commas in the output). If having b as a variable is required, you can use: ...

Only top voted, non community-wiki answers of a minimum length are eligible