Tag Archives: awk

swapping two columns with awk keeping tabulation

Tweet Assuming you have a data file with N columns and you want to swap the first and second one, just type:

To keep the tabulation intact, you need to specify the separator. Incoming separator is defined by -F … Continue reading

Posted in Linux | Tagged | Leave a comment

How to calculate mean in AWK

Tweet Another trick with awk to compute mean of a column. Imagine that you have a file with many lines and you want to compute the mean of the fourth item on each line. E.g:

Using the awk tool … Continue reading

Posted in Linux | Tagged | Leave a comment

How to resize images with awk and convert

Tweet If photos in a directory are too large, you may want to use a script to automatically convert all the files into another format. AWK and convert tools can help you. The following command should convert all the files … Continue reading

Posted in Linux, photos | Tagged , | Leave a comment

Combine AWK and SED to create symbolic links

Tweet The unix tools AWK and SED are very powerful tools to manipulate files and perform text processing tasks. It’s true that the syntax is not always very intuitive but it can help you in performing task in a single … Continue reading

Posted in Linux | Tagged , | 1 Comment

AWK: the substr command to select a substring

Tweet Under Linux, the awk command has quite a few useful functions. One of them, which is called substr, can be used to select a substring from the input. Here is its syntax: substr(s, a, b) : it returns b … Continue reading

Posted in Linux | Tagged | 8 Comments

Awk: how to convert PNG files into PDF

Tweet Here is a method to convert a bunch of PNG files into another format (here PDF). This method works under linux and uses both awk and convert commands (the conversion is made with the convert command). The following script … Continue reading

Posted in Linux, Uncategorized | Tagged | Leave a comment