awk

AWK else if to Python (Pandas)

AWK else if to Python (Pandas) Question: I have the following data: data = {‘f_geno’: ["AA", "AA", "AA", "BB", "BB", "BB", "AB", "AB", "AB"], ‘ch_geno’: ["AA", "AB", "BB", "AA", "AB", "BB", "AA", "BB", "AB"], ‘freq_A’: [0.50, 0.46, 0.49, 0.57, 0.55, 0.44, 0.37, 0.66, 0.46], ‘freq_B’: [0.50, 0.54, 0.51, 0.43, 0.45, 0.56, 0.63, 0.34, 0.54] } …

Total answers: 2

Removing Duplicate Domain URLs From the Text File Using Bash

Removing Duplicate Domain URLs From the Text File Using Bash Question: Text file https://www.google.com/1/ https://www.google.com/2/ https://www.google.com https://www.bing.com https://www.bing.com/2/ https://www.bing.com/3/ Expected Output: https://www.google.com/1/ https://www.bing.com What I Tried awk -F’/’ ‘!a[$3]++’ $file; Output https://www.google.com/1/ https://www.google.com https://www.bing.com https://www.bing.com/2/ I already tried various codes and none of them work as expected. I just want to pick only one unique …

Total answers: 2

Rearranging a list to get the 2nd column entries as rows

Rearranging a list to get the 2nd column entries as rows Question: I have a list associated to strings as follows; A string1^description1`string2^description2`string3^description3 B string4^description4 C string1^description1`string5^description5`string3^description3 D . E string6^description6`string1^description1 F string7^description7 G string1^description1`string4^description4`string5^description5 I would like to switch the first and second columns so that the stings in the 2nd column are the …

Total answers: 3

How to transpose unique entries in a column and print values from another column

How to transpose unique entries in a column and print values from another column Question: I have a file input.txt with two columns, I want to split the second column by ";" and transpose the unique entries then count and list how many matches are in column 1. This is my tab-delimited input.txt file Gene …

Total answers: 2

strstr() alternative for bash

strstr() alternative for bash Question: I need to search a string for a substring, if the substring is found print the string upto the end of the substring.i.e str="this is a long string" substring="long" expected="this is a long" I have tried bash string manipulation and failed. Tried to use an awk command, but I can’t …

Total answers: 3

convert file with multiple lines into array

convert file with multiple lines into array Question: How can I convert a file like: ap-southeast-1 ap-southeast-2 ca-central-1 into: "ap-southeast-1","ap-southeast-2","ca-central-1" What I tried so far: sed -z ‘s/n/,/g;s/,$/n/’ filename Above gives: ap-southeast-1,ap-southeast-2,ca-central-1 Tries xls transpose function but that also no luck: https://support.microsoft.com/en-us/office/transpose-function-ed039415-ed8a-4a81-93e9-4b6dfac76027 Asked By: Kiran Kumar || Source Answers: Extending OP’s current sed: $ sed …

Total answers: 4

Why is awk so much faster than python in this case?

Why is awk so much faster than python in this case? Question: I have a clip list with 200,000 rows, each row is of the form <field 1> <field2> In order to get just field 1, I can run a script that looks like this import os import sys jump = open(sys.argv[1],"r") clips = open("clips.list","w") …

Total answers: 1

Bash script get version from setup.py or from PKG-INFO file and export as environment variable

Bash script get version from setup.py or from PKG-INFO file and export as environment variable Question: I need to get version value from setup.py or from PKG-INFO using bash and extract environment variable with the version value for later use. (Actually I need version value for GitHub Action) from setuptools import setup, find_packages with open("README.md", …

Total answers: 3