Skip to content
Advertisement

Tag: awk

Linux piping data containing backticks

I’m piping output from one command into a second: mpc listall returns the following data (can output 1 or more lines): When piping it into the next command, it seems that my shell (Ash on BusyBox) converts the ´ into an asterisk, as I get the error Manually adding double quotes works! like this: So, I tried adding those by

Finding repeated names in a file

Hi i have a txt file with last name and name of people, now i want do use egrep to only display the names of the people with the same last name. I have no idea how i could do this. Thanks for help my txt looks like this: and the output should be: I’ve currently tried running: …but this

how to print lines with specific column matching members of array in bash

How to print lines when the first column matching members of array(“12” or “34” or “56”)? Add Also, how to print lines when the first column exactly matching members of array(“12” or “34” or “56”)? Answer You could use bash to interpolate the string to a regex pattern used in Awk, by changing the IFS value to a | character

Split string in xml

I have xml file which contains data . I want to split only FATURANO Like that 6-R-7 and 4825 And this “4825” should have different name. I Need convert xml data like that but if u answer me only with first question how to split string correctly i will do other transpormation Answer With single xmlstarlet expression: ed – edit

get user input in awk script and update it in file

I have a students.txt (RollNo, Name, IDU, CGPA), If Roll number exists prompt the user to change the IDU and CGPA and update the same in the file named “Student.txt” I made the following script: now I need help in taking user input for IDU and CGPA values and update the students.text file with that values against the record found.

How To Substitute Piped Output of Awk Command With Variable

I’m trying to take a column and pipe it through an echo command. If possible, I would like to keep it in one line or do this as efficiently as possible. While researching, I found that I have to use single quotes to expand the variable and to escape the double quotes. Here’s what I was trying: But, I keep

Linux cut, paste

I have to write a script file to cut the following column and paste it the end of the same row in a new .arff file. I guess the file type doesn’t matter. Current file: The output should be: how can I do this? using a Linux script file? Answer Brief explanation, ^([^,]*) would match the first field which separated

escape one variable but not the other in awk

I’m facing a problem with awk in Linux. I would like to do make this script work : The problem here is that I want the variable “var” to be interpreted (it works) and the variable $OTHERVAR not to be interpreted, and this I what I can’t manage to do. In the end, I want to do this: I have

Compare different columns of subsequent rows to merge ranges

I have a list of ranges, and I am trying to merge subsequent entries which lie within a given distance of each other. In my data, the first column contains the lower bound of the range and the second column contains the upper bound. The logic follows: if the value in column 1 is less than or equal to the

free -g with sed -n plus nth character

I am trying to create a script to display just one of the numbers from the free command. In my case, the number I want is on the 2nd line of the free -g output and at character slot 43. The original output of free -g is: So far I have gotten the 2nd line to display with: I need

Advertisement