Bash file filter

Asked

Viewed 46 times

0

I am wanting to print specific columns of a file. My file is like this:

                                                   random    random
   kB  reclen    write  rewrite    read    reread    read     write
10240    4096    35383    32281    58250   130504   100674    38425

Has more columns..

bkwd    record    stride                                    
read   rewrite      read   fwrite frewrite    fread  freread

What I want is to print the columns kB, reclen, write, read, Random read and Random write, only.

My code is like this:

#!/bin/bash
for i in {1..15}; do
  iozone -i 0 -i 1 -i 2 -I -s 10M -r 4096 -w -e |tee dataiozone$i.txt
  sed -n '28,30p' dataiozone$i.txt > filter$i.txt
  rm dataiozone$i.txt
done

    grep -v iozone * | awk '{print $1,$2,$3,$5,$6,$7}' > out.txt

The grep I already tested, is really taking all the lines of all the files, the only mistake I’m making should be in awk.

  • When the error occurs ? I used here grep -v iozone a | awk -v OFS=' t' '{print $1,$2,$3,$5,$6,$7}' and it worked. I added tab as tab to make the output more readable

  • grep ... * captures lines from all existing files in the most prudent Talve folder grep -v iozone filter*.txt | ... .Would make it simpler iozone ... | sed ...> filter...txt. What a ride it is?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.