I am trying to convert a csv file like below with bash scripts. Headers and structures are always the same. Source csv file: Conditional values (will change depending on the requirements) Now I am trying to get the following result without the first row and values are now separated by spaces if each header ma…
Tag: awk
Using awk to parse and transform the following log
I have a log like this: I want to parse this log file and get all the following lines: Then I want to transform those lines into the following format for plotting: Here is my awk code: The thing I don’t like for this solution is: I must count manually the index of tokens generated by awk. I prefer a
How to split a single XML file into multiple based on tags
I have an XML file that have tags. I want to split files like this. Below is the code tried . But it is generating every single line into a new file I want to split this file based on ORDER tags alone as mentioned below Answer With any awk in any shell on every UNIX box: it’s obviously fragile
Recover informations from CSV files with my awk script
I have this CSV files : I create a little script that allow me to recover the informations from my csv and to place them like this : My script is : But the result is : Or I want : Can you tell me why my script doesn’t works and why floats are not taken into account ? Thank
Linux/Shell slicing a large text file
Given File1 File2 I wish to make a method that basically does this So given a uniquename from file1 it will use its key from file2 to get what it’s link to. If it doesn’t find uniquename do nothing. MY ATTEMPT Answer The cut utility was designed for this type of data:
Extract text between two known strings in a web page and store in a variable
The web page contains this line: var zx_fn = “string with any possible character”; I download the web page, then I try to to take the part between quotes and store it in a variable my code: It doesn’t work because it says: sed: can’t read And it returns the whole page content Also what…
find matching text and replace next line in yml
I’m trying to find a line in a yml configuration file and replace the next line with a specific value. I tried sed, but it seems it is not replacing or not able to find the pattern. Below is the snippit of that yml file I want to change port value to 14081 for applicationConnectors as there is another p…
How to find encapsulating function name from line number
I am looking at a log file which just tells me the filename and the line number inside that file that has the Error. What I am interested is knowing the encapsulating function. For example, here are the contents of the log file and here are the contents of the file foo.file Based on the above log file, I want
Linux script to check if DNS have the same IP like the one next to it in the same list
I’ve got a list of DNS and IP adresses in this format: DNS IP DNS IP DNS IP And I need to do a script which do dig +short DNS and check if it has the same IP as the one next to it, and that with all the document. The idea is that if it’s the same, it returns
How To Replace Strings With X to Y Characters
I have data similar to the following: I am looking for a way to replace strings in field 2. If the number does not have 10-11 characters, I would like to replace it with 12223334444 so the output would be: My original thought was to use cut to get the second field and then use grep “[1-9]” or some…