Follow me
-
Recent Posts
calendar
December 2024 M T W T F S S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Recent Comments
- Stan on python argparse issues with the help argument (TypeError: %o format: a number is required, not dict)
- Cormac on Pandas : how to compare dataframe with None
- LP on AWK: the substr command to select a substring
- jrab on python argparse issues with the help argument (TypeError: %o format: a number is required, not dict)
- How to disable SSL verification for urlretrieve? – Peter's blog on python: certificate verified failed
Archives
Categories
Meta
Tag Archives: awk
AWK: convert into lower or upper cases
In order to convert a bash variable to lower case with awk, just use this command: a="UPPER CASE" echo "$a" | awk ‘{print tolower($0)}’a="UPPER CASE" echo "$a" | awk ‘{print tolower($0)}’ If you want to convert the content of a … Continue reading
swapping two columns with awk keeping tabulation
Assuming you have a data file with N columns and you want to swap the first and second one, just type: awk -F $’\t’ ‘ { t = $1; $1 = $2; $2 = t; print; } ‘ OFS=$’\t’ input_fileawk … Continue reading
How to calculate mean in AWK
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: Lowest value found .2 Lowest value … Continue reading
How to resize images with awk and convert
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 with … Continue reading
Combine AWK and SED to create symbolic links
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 line. … Continue reading
AWK: the substr command to select a substring
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 number … Continue reading
Awk: how to convert PNG files into PDF
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 generates … Continue reading