Quantcast
Channel: batch awk print from multiple input file to multiple output file - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 2

batch awk print from multiple input file to multiple output file

$
0
0

I have multiple text files, and I wish to extract specific columns from these files and save them to *_2.txt files.

awk '{print $(NF-3), $5}' *.txt > *_2.txt 

But this command is not working. How can I achieve this batch column extraction using awk?

Input:

a.txtaaa bbb ccc          109.6136     93.1900      1.0000    269.7332  35703.1790ddd eee fff            48.8760     34.2100      1.0000    215.0926  35918.2717ggg hhh iii                     17.3588    -65.4900      0.7000  14008.0228  49926.2945...b.txt qq ss rr         105     71.6239     68.1500      3.0000      1.3408   4329.5373aa bb nn         110    271.3443    231.4200     10.0000     15.9395   4345.4768rr uu ii         115    338.2163    415.6700     25.0000      9.5985   4355.0753zz xx yy         120    536.0957    584.7900     50.0000      0.9485   4356.0238...

Target output:

a_2.txt109.6136     93.1900      1.0000 48.8760     34.2100      1.0000 17.3588    -65.4900      0.7000...b_2.txt105     71.6239     68.1500110    271.3443    231.4200115    338.2163    415.6700120    536.0957    584.7900...

I wish to extract specific columns from each text file and save them to each text file with _2 added to the name. Target column is $(NF-5), $(NF-4), $(NF-3)


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>