Extract specific columns from delimited file using Awk

I don’t know if it’s possible to do ranges in awk. You could do a for loop, but you would have to add handling to filter out the columns you don’t want. It’s probably easier to do this: awk -F, ‘{OFS=”,”;print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$20,$21,$22,$23,$24,$25,$30,$33}’ infile.csv > outfile.csv something else to consider – and this faster and more … Read more

nginx error connect to php5-fpm.sock failed (13: Permission denied)

I had a similar error after php update. PHP fixed a security bug where o had rw permission to the socket file. Open /etc/php5/fpm/pool.d/www.conf or /etc/php/7.0/fpm/pool.d/www.conf, depending on your version. Uncomment all permission lines, like: listen.owner = www-data listen.group = www-data listen.mode = 0660 Restart fpm – sudo service php5-fpm restart or sudo service php7.0-fpm … Read more

How to do a mass rename?

Easiest solution is to use “mmv” You can write: mmv “long_name*.txt” “short_#1.txt” Where the “#1” is replaced by whatever is matched by the first wildcard. Similarly #2 is replaced by the second, etc. So you do something like mmv “index*_type*.txt” “t#2_i#1.txt” To rename index1_type9.txt to t9_i1.txt mmv is not standard in many Linux distributions but … Read more