Skip to main content

Posts

Showing posts from November, 2023

Cursor Highlighting in Vim

Most of the time I am using   vim   editor when I need to edit and modify files. In the beginning it looks strange for the people working on Windows since classical Notepad application is much more simple and the graphical user interface provides more simplicity. Having several modes in vim it is making things a little difficult to understand but the strength of the editor stays behinds these modes. Of course we will touch to the cursor highlighting in vim a little later. What we usually start to learn from using vim is to open a file then press i to enable  INSERT  mode, make some changes, and  ESC  to enable  escape mode  and type  :wq  to save and exit or  :q!  to quit without saving. As we all know this is the most basic thing we can perform with vim. Of course within the  ESCAPE  mode, there are many more things that can be done such as replacing strings, adding line numbers, define number of spaces of an indent ...

Passing Variables to Awk

 I ntroduction to Passing Variables to AWK AWK  is one of the most famous commands to use and manipulate the string based files which can be parsed into fields using delimiters and the functionality can even extended with passing variables to awk. It is so much convenient to work with AWK due to its easiness and understandable scripting to accomplish some certain tasks such as filtering fields. The special parameter  -v  is used to pass bash variables or variables inside a script . The general syntax will look like the following. The most important thing is that for each variable that needs to be passed into awk script, they all need to be passed with repetitive -v use.  awk -v var_name=value [-v var_name2=value2] 'AWK script' input_file In a sample input.txt file, say the content looks like as the following. If delimited with space, first column will be the count, second field is the user agent and third field is the agent version. $ cat input.txt 30 okhttp 5.0...