Tag Info

Hot answers tagged


Using awk: awk ' BEGIN { fields[1] fields[3] fields[4] fields[5] fields[6] fields[7] last_field=8 } ( NR%21 in fields ) { printf($0",") } NR%21==last_field' in_file.txt Or better yet: awk ' NR%21 ~ /^(1|3|4|5|6|7)$/ { printf($0",") } NR%21==8' in_file.txt GNU sed has a nice extension to match the nth line after a ...


Here's one way: $ perl -000ne '@f=split(/\n/); print join(",",@f[0,2..7]) , "\n"' file.txt 1500,18,02,09,47,17,45 1501,27,54,28,50,22,03 Explanation: -000 : activates "paragraph mode", it sets perl's field delimiter to \n\n, consecutive newlines. This means that it will treat each of your records as a single line. @f=split(/\n/); : split the current ...


Use Vagrant, it is a layer on top of VirtualBox and provides pre-made images called boxes, amongst them Ubuntu images.

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