I have two files, fisrt "file.txt" have few lines, next file: "output.txt is empty", examples:
cat file.txt
Line1 x i 12gb
Line2 x u 13.7gb
Line3 x q 4.3gb
Line4 x t 33gb
Line5 f t 29.04gb
Line6 f t 38gb
cat output.txt
I need to grep lines only where size is greater than 30 and separate size, f.e. 29.04gb to 29.04 gb (with white char) but i have problem with my script (in awk):
#!/bin/bash
plik=file.txt
OUT=output.txt
awk '{if (30<=$2) print $1, $4}' $plik >$OUT
My output.txt file looks:
Line3 4.3gb
Line4 33gb
Line6 38gb
Can u tell me where is the problem with my awk line ?
and separate size, f.e. 29.04gb to 29.04 gb (with white char)you mean you want a blank char between the number and gb in the output - if that's not chat you want then please clarify that statement.if (30<=$2) print $1, $4you know that the number you want to print is stored in $4 but you're testing the value of $2 instead of $4 to decide whether to print it or not. There must be some reason for that but I can't imagine what it'd be unless your real data doesn't actually look like the example you provided.