awk is a special-purpose, interpreted programming language for extracting and reporting data.

learn more… | top users | synonyms

0
votes
2answers
37 views

Awk scripting help

Hey guys new to scripting and looking to see why I get the following error message: syntax error near unexpected token '$0' using this .sh file to rearrange date and time in a .txt file so that ...
1
vote
1answer
105 views

How to copy a part of a line to another position

I have about 100 print statements in a file like this: printf("%f \n\n",row1.req_pnttime); I want to copy the variable name inside the string so that it becomes like this ...
1
vote
2answers
30 views

Grab a field without a fixed position via awk

I'm working on a script to wake different LCs on my LAN. MAC-Adresses are hard to memorize so I made myself a list that contains information about the respective PCs. Right now the list looks like: ...
4
votes
2answers
57 views

Using Regex Breaking a text on the last digit using linux tools like sed, or awk

I have the following list that I want to break on the digit. For example: From: 103Ru 103mRh 104 1041 To: 103 Ru 103 mRh 104 1041 I would like to use Regx with sed or maybe awk in order to ...
4
votes
3answers
193 views

How can I process multi-line records with awk in a bash script?

example.txt is below Restaurant: McDonalds City: Miami State: Florida Address: 123 Biscayne Blvd Phone: 911 Restaurant: 5 guys City: Atlanta State: Georgia Address: 123 Peachtree Rd Phone: 911 ...
1
vote
1answer
64 views

split string with awk and delimiter

i have log file like : 1:: 10:: 127.0.0.1 172.17.1.1 i want awk to split string to columns on :: delimiter. some thing like : awk {print$1} and the result : 1 and awk {print$2} and the ...
1
vote
2answers
38 views

how to trim dpkg upgraded packages list

Latest upgrade borked my system and I`m trying to revert the last upgrade. I opened my comp with live USB and chrooted to partition that is OS installed. I get the upgraded packages with cat ...
0
votes
1answer
108 views

sed, grep, and awk file sorting

I'm trying to get all the files which have 'load' in their names from a directory. I'm trying to do: find -type f | sed -s 'load However, I recurrently receive an error sed: -e expression #1, char ...
0
votes
1answer
55 views

Download AWK to Ubuntu

How to download awk to Ubuntu, since I tried to use asorti function and it told me that there is an error on this asorti. I tried many scripts that used asorti function and the same error occure!
0
votes
1answer
99 views

Syntax error in awk program

I want to check the method of IP-Assignment as in this question. I'm running it in bash on Ubuntu 12.04. My Problem is the function "get_con_id()" gives me "Syntax error" at the if-clause. The script ...
0
votes
1answer
91 views

Concatenation in Shell Scripting Bash

I wanna check if 2 lines have equal $4 my shell must check if the diffrence between $3 in line 2 and $2 in line 3 is equal 1 it must concatenate both line into one like this 1;1000000000;1099999999;2 ...
0
votes
1answer
25 views

Sort FileA into FileB while actively removing lines from FileA

I tried simplifying the title, apologies if it's somewhat confusing. I have a large text file (File A)(around 13GB) and I want to sort through it (into File B) to delete duplicate lines. Problem is I ...
-1
votes
2answers
87 views

Reading a file line by line

I have a file that looks like: @ATDGGSGDTSG NTCCCCC + nddhdhnadn @ATDGGSGDTSG NTCCCCC + nddhdhnadn Now its a repeating pattern of "4" lines and I every time want to print only the 2nd line i.e. the ...
0
votes
1answer
30 views

Formatting a file to use it with fortune in the terminal

I have a big text file with 'Terms' and its 'Definition' separated by spaces(variable). I want to use it in fortune cookie format. Current file format: **term1** this is my definition with ...
2
votes
3answers
126 views

Print multiple lines starting with “D” after multiple greps

I have two text files. Text-file-1 contains strings (one string per line); C 010 C 020 C 024 . . . Text-file-2 contains data in following format; C 005 Carbon D Carbon 1 D Carbon 2 D Carbon 3 D ...
9
votes
2answers
2k views

What does this command mean: awk -F: '{print $4}'?

Please explain what does following command mean: awk -F: '{print $4}'
2
votes
4answers
197 views

Using if an AWK command

I have a file which contains many sub-sections each starting with [begin] and ending with [end]sample of which is shown below: [begin li1_1378184738754_91] ...
2
votes
2answers
352 views

How to write an awk script that catch ping's time

In this line: Reply from 10.11.12.13 time=1035ms how to write an awk script which brings out just 1035.
2
votes
1answer
185 views

Subtitle Overlapping: How to comparing two timelines in subtitles (e.g. 00:18:06 vs 00:16:01) and overwriting one of them if it's overlapping?

I have a series of srt files (film subtitles) that some of their time-lines overlap each others on the video! This means that some of time-lines are displayed about 1-2 seconds longer than they are in ...
3
votes
2answers
170 views

How to batch organize files?

I have a directory with gigabytes (about 8gb) of small individual files. I want to organize them into directories by date. The date it was created is part of the filename. Here is an example of a ...
1
vote
1answer
47 views

Skip records containing no field separator in awk

In awk, I am using / as the field separator. However,there are some records in the input file that do not contain this field separator. How does awk behave for such records? Is there any way to tell ...
1
vote
2answers
941 views

awk programming - Changing a field value conditionally

I'm a beginner in awk programming. This post is to clarify a doubt. I have file like this: 70 17 5 mb 71 18 6 ms 72 19 7 ml 73 20 8 mw in which 4th column is a string. I want to make changes in the ...
1
vote
0answers
116 views

Grep word in one file, and use that word to match in another file, adding the thing that follows the match

I want to grep several words in file1, and use each word to grep what follows after its match in file2. And then I want to add the thing that followed the match to the word I used into file03, so that ...
3
votes
1answer
210 views

Why doesn't this command work as an alias?

I've been using the following command to list the ten largest files, at any depth, under the current directory: find -type f -size +10M -exec ls -gGsSh1 {} + | awk 'NR<=10 {print $0}' (I use awk ...
4
votes
2answers
134 views

Print text file every three line start at 2nd line

I have done it with simple loop to count and print through.. How can I do it in bash scripting with program such as sed,awk ?
2
votes
2answers
117 views

Help using Awk to change a file

I am using awk to simply change some text in a file, while maintaining the values as they are currently in the file. The problem is a few of the values are changing. the values are maintained if i ...
2
votes
1answer
138 views

Need help in SED and AWK

I have a file "list" as following: main.c getname 25 main.c getage 36 util.c namecheck 123 The above has first string file name, second function name, and third line no. I want to: Open the ...
2
votes
1answer
94 views

awk quoting program text

I just came across a gotcha in awk, and I would like to know if anyone can explain to me why this happens. The following 2 lines behave differently if I run: # grep -Rl BASE_DIR --exclude-dir=.svn * ...
2
votes
5answers
267 views

sed/awk make lines starting with lower characters be merged to previous line

Here is what I have This is a sample text How to do it ? I need the output to be: This is a sample text How to do it ? In addition, how can I achieve the same with: This is a sample text How ...
1
vote
0answers
143 views

sed/awk - remove all tags except only two tags and plain texts

here is a sample for my text file: <w:r><w:t> <w:r w:rsidR="00D171FD"> <w:t></w:t> </w:r><w:r> <w:t xml:space="preserve"> This is a sample text ...
3
votes
2answers
3k views

How to get separate with space or tab in the awk example

while I'm playing with awk I came to execute like ls -la >> a.txt ; awk {'print $5 $1'} a.txt ; then its giving output like 53277-rw------- 52347-rw------- how can I get space between ...
4
votes
2answers
162 views

Using awk or similar to find the next word in the output of another command

I am trying to determine the Startsector of a .img file from within a bash script so it can be correctly mounted from within the script. I have been using the file command to easily find the ...