Most voted "awk" questions
It is a line-by-line language and its main purpose is to make Shell scripts in Unix/Linux more powerful and with many more features without using many command lines (can solve infinities of everyday problems of the developer in these operating systems). It is widely used to process data with text and file manipulations.
Learn more…22 questions
Sort by count of
-
6
votes2
answers143
viewsCopy all before the first blank line
I have a file with several text blocks, separated by blank line. Ex.: block1 block1 block2 block3 block3 I need a solution with sed, awk or perl that locates the first blank line and redirects the…
-
4
votes2
answers246
viewsAWK regular expression print inside brackets
look, inside my.txt file has the following description: Flags: X - disabled, E - established 0 E name="peer1_cymru" instance=default remote-address=38.xx.xx.xx remote-as=65555 tcp-md5-key="WUf4f8"…
-
3
votes2
answers479
viewsHandling dates in AWK scripts
CONTEXT: I have a CSV file from which I want to extract and process some columns. I realized that AWK would be the perfect tool for this and everything was fine until I had to deal with timestamps -…
-
3
votes4
answers249
views -
2
votes1
answer244
viewsFour different conditions using awk if (Unix)
Hello I need to do an awk if command using 4 different conditions together, example of my input just for a few lines (I have an input with thousands of lines) chr17_30 1 chr1_72 0 chr1_46 2 chr1_47…
-
2
votes3
answers507
viewsTransform date format DD/MM/YY into MM/DD/YY into Shell Script
The script reads the date of a . txt in DD/MM/YY format, and I need to convert it to MM/DD/YY format with Bash, Sed or AWK.
-
2
votes2
answers81
viewsHow to print Ipv6 Global using grep and awk?
It’s been a few days since I’ve been searching the Internet for such an answer, but I haven’t had one so far. I am trying to print Ipv6 Global from ifconfig to be used in MOTD on Ubuntu. With Ipv4…
-
2
votes2
answers522
viewsInsert string in first column
I am breaking my head with something very simple, I need to insert a ";" (point and comma) after a Sort/Uniq in a file. As it returns the number of repeated lines, I need this return that is always…
-
2
votes2
answers1499
viewsRemove all line breaks from just one column of a csv file on Linux
I have a file csv with more than 500k of lines and need to remove line breaks from just one column efficiently in addition to deleting all the links it contains, a snippet of the file:…
-
2
votes1
answer135
viewsCreating a file from a list and several different files
I have a list of names and several different files that may or may not contain all the names in the list and a value assigned to the names. I need to compare the values of all these each file to the…
-
2
votes2
answers186
viewsUnexpected output when printing substring
I’m doing a file search in a given directory and printing its respective path. find ./ -exec sh -c "echo $(dirname "{}")" \; Output: ./algo/desse/tipo Since in some cases this path is a little big,…
-
2
votes1
answer26
viewsFilter two lines of the file at the same time show only the second?
I have the following fictional file: Location: Estado Title: Bahia Location: Estado Title: Pernanbuco Location: Estado Title: Alagoas Location: Cidade Title: Recife Location: Cidade Title: Barretos…
-
1
votes1
answer85
viewsDelete words from a file
I have a file CSV and I have this list of words here: https://gist.github.com/alopes/5358189 The archive CSV has 3 columns, Text, user.name and Class and has about 100K of rows. I need to delete…
-
1
votes3
answers102
viewsLinux - Edit multiple files using another file as source
I have a file (list name.txt) with several names, one per line. I need to edit or remove all the names that are on listanome.txt of several other files With grep I think which files should be…
-
1
votes1
answer80
viewsCondition where you find the name "test" I print OK if NO
this is the code I’m trying to solve and its result! awk '{if ($0 ~ "teste") { print "ok"} else {print "no" }}' arquivo.txt no ok no no no as you can see he checked every line himself had the name…
awkasked 5 years, 6 months ago socket plus 15 -
1
votes1
answer372
viewsHow to assign a variable the sed command with formatting? Shellscript
I’m having a problem making a program to exchange the first number for X, because even if it works, the variable does not receive the value permanently: VAR="oi 200 20 10" VAR= echo "$VAR" | sed -r…
-
1
votes1
answer95
viewsReplace columns of a row when another column starts with a specific word
I need to replace a letter from a column every time it finds a specific word in the file. Example: In the lines below, whenever you find the word PEDRO in a row in column 4, I have to replace "P"…
-
1
votes1
answer42
viewsCan you insert a variable by passing it as a regular expression in the awk command?
Example: VARIAVEL="Pará" echo "$VARIAVEL" | awk '/^P/ { print $1 }' What this does is just search for any word started with a capital letter P. Okay, so far so good! Now, I want to know if you can…
-
1
votes1
answer38
viewsI need to delete the line that matches a word in the first file and also the second file in the sequence. How do I do?
I need to delete an entire line through a word that I will define and at the same time delete another line as well, but now it must be in another file that corresponds to the line of the first file.…
-
0
votes1
answer149
viewsExtract substring from a bash line with a Pattern
Good afternoon to all, I have a text file with several lines with fixed columns: 11Sala 1:4 FF The first column has the ID, and the second has the data I want to get (1:4), but when I have lines in…
-
0
votes1
answer27
viewsas it adds a name below a specific search
I have a file with the name lista.txt cat lista.txt nome1 nome2 nome3 now I have searched the name with specific awk awk '/nome2/' lista.txt nome2 awk brings me the name I seek!! now I want to add…
awkasked 5 years, 6 months ago socket plus 15 -
-1
votes1
answer42
viewsTaking the title of an HTML page with sed or awk
I have several HTML pages that I would like to get the title by using the sed or the awk. When I do with the sed it returns all the content of the page, not just the title. On the pages the title…