AWK is a text-processing language. It is mainly used to manipulate and process structured data, and to generate reports.

learn more… | top users | synonyms

0
votes
1answer
194 views

script to convert GB to TB

I have (multiple) files like below list. Few of them has both the values in TB and couple of files in GB. Now if you clearly see the file output there are two rows with Total capacity and Capacity ...
2
votes
1answer
161 views

Delete first lines from a Unicode html file

I have an HTML file that is in UTF-8 format and I want to remove the first five lines from it. I've tried using sed but it doesn't work in this case: sed "1,5d" Result.html>small2 It actually ...
2
votes
1answer
129 views

Grep the whole body of a function

Supposing I know that someFile.php contains the definition for someFunction(). How would I go about displaying the whole body of the function in stdout? If I know that the body is 10 lines long then I ...
2
votes
4answers
660 views

How do you remove all occurrences of values in one list from another list?

I have a list of symbols such as... wer sfe efo How do I remove all instances of these (unique) symbols from another list of (non-unique) symbols? So in the following list, the lines starting ...
3
votes
4answers
980 views

Using grep to display second character in string?

I have a string that is always 3 characters... the first one and the last one are always the same. example: ▁▅█ Is there a simple way to only display the one in the middle? (which is the only one ...
3
votes
1answer
137 views

Parse by Control Characters

I am trying to parse the output of a command that expects to be writing to the screen. It has data separated by move-to-origin control sequences (for the VT220, ESC[1;1H). I only need the last part ...
1
vote
0answers
14 views

FTP over'd image files with transfer-type: ASCII; possible to revert? [duplicate]

Possible Duplicate: Recovering corrupted files uploaded in wrong FTP mode undo effect of ASCII ftp transfer I've downloaded hundreds of files from a Drupal install using FileZilla. ...
1
vote
1answer
231 views

Using awk/nawk, how to find out max and min contributions and printout those values?

Using awk/nawk, how can I find max and min contributions and print those values? Input file: Name: Phone:1st:2nd:3rd contribution Mike Harrington:(xxx) xxx-xxxx:250:100:175 Christian Dobbins:(xxx) ...
2
votes
3answers
318 views

using nawk, how to sum all numbers in $1, $2, and $3 fields?

using nawk, how to sum all numbers in $1, $2, and $3 fields? 8 6 2 7 3 5 1 9 4 I want the result to be sum = 45
0
votes
4answers
1k views

How to recursively remove all .exe files from all the subdirectories of the current directory?

I have a USB containing important files. However it is infiltrated with some unwanted .exe files (probably virsuses) in each subfolder. Since I am on a Linux machine, the exe files won't affect me. ...
0
votes
1answer
1k views

solaris 10 + display 2 lines after match by grep?

how to match string , and display the two line under the string for example ( I want to match the "manufacture" string and display the two lines after cat ima.conf # the manufacturer or driver ...
-1
votes
1answer
67 views

Using nawk, how to print the first names for all those in the 916 area code? [duplicate]

Possible Duplicate: Using nawk, how to print all first names containing four characters? Using nawk, how to print the first names for all those in the 916 area code? I've tried nawk ‘$3 ~ ...
-3
votes
1answer
84 views

Using nawk, how to print all first names containing four characters?

Using nawk, how to print all first names containing four characters? I tried nawk ‘/^[[:alpha:]]{4}/{print $1}’ inputfile but didn't work Mike Harrington:(510) 548-1278:250:100:175 Christian ...
1
vote
2answers
853 views

How to extract e-mail or domain from mixed data file in linux

File content: 17541 From Email subscription@test.com Inbound Policy Manager Envelope Analysis Profiler 17541 From Email subscription@yahoo.com Inbound Policy Manager ...
0
votes
1answer
167 views

Filtering output from the “dscl -readall” command

dscl . -readall /Users outputs something like this (only a part of the entire output): PrimaryGroupID: 20 RealName: Johnny Smith RecordName: johnny RecordType: dsRecTypeStandard:Users UniqueID: ...
1
vote
5answers
2k views

How to grep column after second pipe

Example: 3|100|test@test.com|0|0|6:1,10,11,12,13,2,3,4,5,6,9|7:1,10,11,13,16,2,4,5,6,9| Expected view after grep: test@test.com
1
vote
2answers
147 views

Using sh -c in terminal

I have this command line that I enter into terminal and it works as intended: dscl . -readall /Users UniqueID | awk '/^RecordName:/ {name=$2}; /^UniqueID: / {if ($2 > 500) print name}' What I ...
0
votes
3answers
199 views

Replacing quotes in a file

I have a large number of large semicolon-separated data files. All string fields are surrounded by double quotes. In some of the files, there are extra quotes in the string fields, which messes up the ...
4
votes
5answers
1k views

Using awk to split text file every 10,000 lines

I have a large gzip'd text file. I'd like to something like: zcat BIGFILE.GZ | \ awk (snag 10,000 lines and redirect to...) | \ gzip -9 smallerPartFile.gz the awk part up there, I ...
2
votes
1answer
239 views

Input field separator in awk

I have many large data files. The delimiter between the fields is a semicolon. However, I have found that there are semicolons in some of the fields, so I cannot simply use the semicolon as a field ...
0
votes
3answers
155 views

Use Sed/Awk to fix faulty SRT files

Recently I downloaded some badly formated SRT files, having the time format messed up as HH:MM:SS:XXX whereas it should be HH:MM:SS,XXX The main problem now is to replace the third colon with a ...
2
votes
2answers
88 views

awk search in specific columns

We have a file like this (with many more lines): BeginJobID=S0065546 JESMSGLG(1/281) jname=CICWCMWD queue=EXECUTION JESMSGLG(2/281) BeginJobID=S0065568 jname=CICWWUWD queue=EXECUTION ...
2
votes
1answer
74 views

Substitute large numbers of files according to style guide

I'd like to do a wholesale reformatting of our tests, and I'm cleaning up some inconsistent capitalization. I'm thinking of using awk to do this, since sed falls a little short, and since I need ...
3
votes
1answer
1k views

How do I parse file paths separated by a space in a string?

Background: I am working in Automator on a wrapper to a command line utility. I need a way to separate an arbitrary number of file paths delimited by a single space from a single string, so that I may ...
0
votes
2answers
422 views

linux sort -n uniq -c

I have a text file which contains about 50MB of text: valA valB valC valZ valB Whats the quickest way to: cat the file Display the unique appearences
0
votes
3answers
180 views

How to search file for matching whole lines?

I have a command which sends to stdout a series of numbers, each on a new line. I need to determine whether a particular number exists in the list. The match needs to be exact, not a subset. For ...
2
votes
1answer
1k views

How to use awk separator of single quote?

I'd like to use awk to pull out information from SQL output like the following: (count(distinct serverclass)='2') And need to extract the number, which is 2 in this example. I'd like to do ...
2
votes
2answers
322 views

Grep, find line with minimum x words

Is there a way to find all lines with grep, that contains at least x words?
1
vote
1answer
220 views

mutt can't get password from an encrypted .gpg file

I am trying to get the imap/smtp password for my email accounts in mutt by parsing an earlier decrypted .gpg file via awk, and assigning the result to a variable used in .muttrc # Process the ...
3
votes
5answers
3k views

How to split a text file into multiple text files

I have a text file called entry.txt that contains the following: [ entry1 ] 1239 1240 1242 1391 1392 1394 1486 1487 1489 1600 1601 1603 1657 1658 1660 2075 2076 2078 2322 2323 2325 2740 2741 2743 ...
2
votes
2answers
141 views

Count elements in lines with awk

I have a tab-delimited text file containing data like Col 1 Col 2 1 a 1 b 1 c 1 d 1 d 2 a 2 b 3 a so on and so forth. I would like to transform this structure into ...
1
vote
1answer
340 views

How to calculate and group the time differences of specified syscalls when running strace

I'm planing to do some web performance testing (to see how much time it's spent for each file), but it could be useful for any application. I exactly know existence and how to use different ...
1
vote
2answers
291 views

Parsing .co.uk whois with awk

I wonder if someone could tell me why these awks are not working, they should supply the registrar and the expiry date : ${AWK} -F: '/Registrar:/ && $0 != "" { getline; ...
5
votes
3answers
441 views

Search for files with more than one term (grep, awk?)

I am using a command like this to find files with the word 'term' in them: grep -l term * But I now want to be able to find files which have two different words in them (let's call them termA and ...
0
votes
1answer
115 views

how to get access to environment variables from output file

I want to get variables from a output file specific location,and input file format as below: log1.txt format: [v] Output Data ...
3
votes
3answers
155 views

unix command to verify span of word in text

What unix command(s) can I use to determine the line span that a word appears in text? The "span" being equal to the line number of the last instance of a word minus the line number of the first ...
0
votes
0answers
117 views

XML text transformation

I have a large file part of which is like below: <DataGroup xsi:type="ReportDataGroup"> <SmartReportTemplate DescriptionContentType="text/plain" IsActive="true"> <Name ...
0
votes
4answers
221 views

Bash script to get specific prior context

I am searching through some log files where there are groups of actions performed. At the start of each group there is a line that has information about the group and then lots of verbose informion ...
2
votes
1answer
78 views

sanity check file to produce binary answer

What Unix command(s) can I use to determine the existence of each of several words and the non-existence of each of several words which will produce a binary answer? For example: I want to be sure ...
0
votes
1answer
357 views

IP Address dotted decimal to /8 or /16 notation using bash,sed or awk?

I have an input file that contains a list of ip addresses and the ip_counts(some parameter that I use internally.)The file looks somewhat like this. 202.124.127.26 2135869 202.124.127.25 2111217 ...
2
votes
3answers
336 views

How to substitute multiple lines between delimiters

Given the text example: .... text ,.. {{{python string1 = 'abcde' string2 = '12345' print(string1[[1:3]]) print(string2[[:-1]]) }}} .... text ,.. The [[ and ]] also appear outside of {{{ too. ...
8
votes
5answers
10k views

How to get the pid of a running process using a single command that parse the output of ps?

I am looking for a single line that does return the pid of a running process. Currently I have: ps -A -o pid,cmd|grep xxx|head -n 1 And this returns the fist pid, command. I need only the first ...
0
votes
1answer
178 views

list files with full modification date

I want to produce a list of files in a directory and feed it into a script to generate database entries including their creation dates. The database is Solr, so I need to be able to translate ISO 8601 ...
0
votes
2answers
1k views

Convert an ascii character to ascii hexadecimal representation

How do I convert an ASCII char to ASCII HEX in a AWK script? I want loop by a range of letter example for(i="a"; i<"g"; i++) print i; NOTE: I want loop by a range from hex representation and ...
2
votes
2answers
237 views

Why is awk printing this line more than once?

I have the following ldif: dn: cn=Robert Smith,ou=people,dc=example,dc=com objectclass: inetOrgPerson cn: Robert Smith cn: Robert J Smith cn: bob smith sn: smith uid: rjsmith userpassword: rJsmitH ...
3
votes
2answers
2k views

How can I identify non-ASCII characters from the shell?

Is there a simple way to print all non-ASCII characters and the line numbers on which they occur in a file using a command line utility such as grep, awk, perl, etc? I want to change the encoding of ...
0
votes
1answer
257 views

ping|awk not responsive

While trying melodyping, I noticed that ping <host> |awk '{print $1}' takes about 30 seconds until the first line is actually displayed. Even though w/o piping to awk each ping is returned in ...
0
votes
2answers
155 views

Generate new file with specific structure from text file

On Linux I have the file orig-file.txt. This file include 4 fields now, but they could be less or more (this file is generated by other application). What is the best option to translate the ...
0
votes
1answer
1k views

Parsing out specific URLs from local html file

I want to parse out certain URLs from a saved html-file with a simple bash-script/command, so i can download them via wget laters. What i have so far is: awk 'BEGIN{ RS="<a *href *= *\""} NR>2 ...
0
votes
2answers
106 views

Generate a files list and truncate it in 2 list of X Mb of files each

I need to generate a list of all files in a certain dir, and truncate it in X lists containing each one a fixed amount of data of files. E.g. I have 95 Gb of data. generate the file list ...