44606

Awk: Length of column number

Question:

I have a (maybe) silly question.

My data: File 1

1234.34 a 1235.34 d 3456.23 b 3457.23 e 2325.89 c 2327.89 f

I want something like

awk '{if($1==$3) print $4}'

But of course if I do this, it will print nothing. So I want to modify the "precision" of $3 (in this case)

in the sense that when awk read $3 it finds this:

124 345 232

then it must be a way to do this, but I don't know it.

awk '{if($1==(three digits precision $3)) print $4}'

Help?

Answer1:

You could calculate the difference of the two values:

awk '$1 - $3 < 0.01 || $3 - $1 < 0.01 {print $4}' file

Recommend

  • Replacing all non-ASCII characters, except right angle character in C#
  • Posting a php variable to a new window
  • co-ordinate of the matched SIFT keypoints
  • opening a popup in IE - “Member not found”
  • Python: Memory-efficient matrix creation for sets of 1's, -1's, and 0s to be optimized by
  • How to change attribute of object in C++ from static method
  • How to change attribute of object in C++ from static method
  • How could I use one route with git for multiple developers in Laravel 4.2
  • .Net WikiText to HTML Parser [closed]
  • Java Out Of Heap Space Error
  • can't seem to find std::thread in msvc++ 2010 express
  • How addSelect() Builder method works in Laravel
  • https://example.com/admin redirects to https://admin in Django Nginx and gunicorn
  • ASP.Net MVC Html.Raw with AntiXSS protection
  • Injecting arguments in scrapy's pipeline
  • Very Basic JS Coding, and SoundManager2 or not?
  • dismissModalViewControllerAnimated shifts view down
  • SVG .end event not working?
  • $this->db->insert_id(); returning 0 every time in codeigniter [duplicate]
  • Getting socket.io namespace from anywhere in the project
  • Maple: How to insert a command to force my code to choose random integer values to find my values?
  • Enterprise Architect - Cancel Connectors Bridges
  • Update SQL MS Access 2010
  • Best practice for switching iPhone views?
  • How to autopopulate a field in SugarCRM form
  • OOP Javascript - Is “get property” method necessary?
  • Ajax Loaded meta Tags
  • Xamarin Forms - UWP Fonts
  • Master page gives error
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Redux, normalised entities and lodash merge
  • align graphs with different xlab
  • Return words with double consecutive letters
  • Arrays break string types in Julia
  • embed rChart in Markdown
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • Reading document lines to the user (python)
  • How can I use `wmic` in a Windows PE script?
  • Unable to use reactive element in my shiny app
  • Python/Django TangoWithDjango Models and Databases