awk - pattern-directed scanning and processing language

learn more… | top users | synonyms

11
votes
1answer
2k views

Making a progressbar with “dialog” from rsync output

I'm looking for a way to filter/redirect rsync output in a manner where it can be fed to the "dialog --gauge" command, so I can get a nice looking progressbar during file sync. Currently I have only ...
2
votes
4answers
5k views

awk-Printing column value without new line and adding comma

input.txt EN1 EN2 EN3 EN4 EN5 output EN1,EN2,EN3,EN4,EN5 I have tried awk.But it is not printing with comma awk 'BEGIN { OFS = ","} { printf $1}' input.txt I have GNU Awk 4.0.0 version
3
votes
2answers
258 views

Print row contain maximum and minimum value

I need to read the file (contains 16K rows)and print the entire row if any of columns and all columns contains max value (100) and all columns contain min value (0).The ouput example is given ...
3
votes
2answers
2k views

AWK-Find maximum value in a row & print with header

I need to read a file, find the maximum value in each row, and print the ID of the row, the column the maximum value came from (sno#), and the value from the associated lc# column. If the maximum ...
4
votes
5answers
1k views

extract fields from “tail -f” of a syslog stream

Example line from syslog file: Aug 1 10:25:50 10.10.10.1 id=firewall sn=XXXX time="2012-08-01 14:35:18 UTC" fw=x.x.x.x pri=6 c=1024 m=537 msg="Connection Closed" f=11 n=195273698 ...
4
votes
3answers
560 views

Print a line only if the next line does NOT contain a particular match

I am trying to search a log file for logged activities that did not complete. For example, I log a "Starting activity for ID 1234..." and if successful, the next line will be "Activity 1234 ...
1
vote
2answers
220 views

Matching values within columns

I have tab-delimited text file containing about more than 1500 rows. input.txt id sno1 EN1 Nucus_2158_mri_1/2_Co_1.0_Le_3104 EN2 Nucus_2158_mri_4/2_Co_1.0_Le_3104 EN3 ...
4
votes
2answers
2k views

Working with columns - awk and sed

I am trying to parse a text file that is generated by an expec script that pulls down some information from a switch. Here is a sample output: 192 0000.0000.0000 1/g23 Dynamic ...
5
votes
2answers
6k views

Join two files with matching columns

File1.txt id No gi|371443199|gb|JH556661.1| 7907290 gi|371443198|gb|JH556662.1| 7573913 gi|371443197|gb|JH556663.1| 7384412 gi|371440577|gb|JH559283.1| ...
3
votes
3answers
1k views

Piping in awk scripts

I'm trying to write a ls wrapper that uses awk to parse the output of ls -lhF. Right now I've split the program into two files - my_ls.sh and my_ls.awk. my_ls.sh's only purpose is to pipe the output ...
0
votes
1answer
531 views

Extract value from different column and replace in another column

I am a biologist, I need one more help in text file editing. I would like to get the help of computer experts ##fsdfsd ##sdd-ver gen 5.5.7 Xm Gen CDS 1 148 . + . ...
2
votes
1answer
214 views

text processing-perl

I am a biologist. I would like help of computer experts to help in text file editing. Here is what the input file looks like: ##dsfsd2 ##sdf-sdf sasg 5.6.3 gi34_ex Gen CDS 161 317 . ...
4
votes
2answers
5k views

Compare two file columns

I have long text files with space-delimited fields: cat file1.txt Id leng sal mon 25671 34343 56565 5565 44888 56565 45554 6868 23343 23423 26226 6224 77765 88688 87464 6848 66776 23343 63463 ...
4
votes
2answers
290 views

How can I get awk to print both matches and non-matches?

Basically, all I want to do is alter outputs if the input matches a filter, but the part being altered isn't what is being filtered (or I would use sed). The problem so far is that my awk is only ...
3
votes
2answers
340 views

Parsing a text-file table and aggregating information

I have long text file with the following columns, space-delimited: Id Pos Ref Var Cn SF:R1 SR He Ho NC cm|371443199 22 G A R Pass:8 0 1 0 0 ...
9
votes
3answers
2k views

How to sort the string which combined with string + numeric using bash script?

This is the data what I want to sort. But sort treats the numeric to string, the data it no sorted as I expected. /home/files/profile1 /home/files/profile10 /home/files/profile11 ...
3
votes
6answers
1k views

Text file look-up by column

I have a file in this format: [#] OWNER_NAME NAME SIZE [6] Robottinosino Software 200 [42] Robottinosino Ideas worth zero 188 [12] ...
4
votes
2answers
260 views

only output when first columns are the same

INPUT: [USER@NOTEBOOK ~/proba] find . -type f | xargs -I "{}" md5sum "{}" | sort 18b17ef2e55f6fd2deb044943a8a769d ./yes 2b00042f7481c7b056c4b410d28f33cf ./tt.txt 2b00042f7481c7b056c4b410d28f33cf ...
2
votes
4answers
676 views

shorten long lines in a log file

I keep a logfile of a program's output. The trouble is sometimes errors occur dumping very long lines of 7bit ascii data(encoded binary) I don't care to keep. These lines can be 200KB+ long before ...
3
votes
1answer
945 views

Make awk use bash with the system() command

Is there a way to make awk use bash instead of sh when running system commands using the system() call? I want to use some bash-specific features such as [[ ]] and < > string comparison operators: ...
0
votes
2answers
3k views

Replacing one test string with another in particular column

I would like to replace "CC" with "C" and "AA" with A" in a particular column of Tab delimited file (using awk probably).
19
votes
11answers
2k views

Remove duplicate $PATH entries with awk command

I am trying to write a bash shell function that will allow me to remove duplicate copies of directories from my path environment. I was told that it is possible to achieve this with a one line ...
3
votes
2answers
238 views

Subtracting one text string from another leaving unique characters, perhaps using awk

Is there any way to subtract one column of data containing text from another column containing text and get third column containing unique charcters, for example using awk eg. Input ab a cd d ...
1
vote
1answer
730 views

Extract marked strings from text file using Bash

I have files which are of the following style - these are parametrised configuration files; the values within the #characters are replaced with real values from a database depending on environment. ...
-5
votes
1answer
246 views

sed and awk challenge [closed]

Here is a great challenge for someone to attack! Is there a way to achieve the following using sed and/or awk. Please see myfile.txt below: $cat myfile.txt: entry "entry-header" entry-top name ...
2
votes
3answers
1k views

Grepping several lines from Nmap output

I apologize in advance as this is a simple question. So I'm attempting to scan a Class C to identify all mail servers by IP. The vast majority of IPs aren't mail servers. I'm trying to filter out the ...
1
vote
1answer
527 views

Append timestamp to top command output

All, I'm using top -l 0 -s 1 -pid XXX -stats rsize | awk 'NR%13==0; fflush(stdout)' > output.txt to store the rsize value of a process in a file. Currently the contents of output.txt look ...
2
votes
2answers
213 views

How do I ad an if statement (regarding punctuation in a word) to this bash script

I have this bash script #!/bin/bash cat $@ | while read line do for word in $line do echo $word | circling-the-square # here's where i need to add the if statement: ...
2
votes
2answers
195 views

How to make a list and count LaTeX keywords in a source file?

I am a beginner, trying to make lists (and eventually count and make statistics) the LaTeX keywords appearing in some documents. Basically a LaTeX "valid" keyword can be identified by: The fact ...
2
votes
3answers
513 views

How can I turn ugly output into pretty, useful information?

How can I turn this ugly output into pretty, useful data? The output: /* ---------- TA#box#AbC_p ---------- */ insert_job: TA#box#AbC_p job_type: a #owner: bob permission: gx date_conditions: 1 ...
1
vote
2answers
116 views

How to parse fields out of a text file and write them to another file

I have executed a database command and have generated an output file of the results. Each field name starts with dbt_xxxxxx Each field value is the value after the equal sign. how can I parse the file ...
4
votes
3answers
322 views

How to parse a file to extract 3 digits numbers kept in a “group number”

I am a beginner, and trying to write a shell script to parse a text file that is extracted from a standardization pdf file. I would like for each test group (identified by Group 0, Group 1... to get ...
1
vote
1answer
740 views

AWK - change the file name (special characters)

I have two files: ~/Pulpit/kot$ find . -name "*jpg" -printf "%f\n" 1.jpg `[~!($%^_&*){.}\___"`]`1.jpg I want to change their name to: _home_pic_Pulpit_kot_1.jpg ...
4
votes
1answer
1k views

escaping a single dot with double backslash - awk

"effective awk programming" book has an example on Field-Splitting. here is the example: If you want fields to be separated by a literal period followed by any single character, use ‘FS = ...
5
votes
3answers
5k views

How to sed only that lines that contains given string?

INPUT: Select ASDF 325 sdfg sdflk lk Select TRG 46sdg rasdftz fsgs 45 Select ASDF 6ffg sdfg 4456 sdrg OUTPUT: Select ASDF 325 XXXX sdflk lk Select TRG 46sdg rasdftz fsgs 45 Select ASDF 6ffg XXXX ...
5
votes
2answers
130 views

Sort fields inline

I'm trying to sort within a line of input over an unknown number of fields: Input: ab bc bc ab cd ef bc bc cd ef cd bc ab ef ab bc cd gh Output: ab bc ab bc bc cd ef bc cd ef ab cb cd ab bc cd ...
0
votes
2answers
1k views

Using awk to process ls output with spaces in filenames/paths

All, I have a script in which I use find command to filter out all png files in a given folder and list them along with their size. I want the output in the following format: someFile.png => 1.2K ...
2
votes
3answers
3k views

How to delete files filtered out by awk

I have the following files in a directory: -rw-r--r-- 1 smsc sys 46 Apr 22 12:09 bills.50.1.3G.MO.X.20120422120453.Z -rw-r--r-- 1 smsc sys 28 Apr 22 12:15 bills.50.1.3G.MO.X.20120422120953.Z ...
2
votes
1answer
843 views

file, awk and iconv to automatically adapt tex-file encoding

I have a set of tex-files with mixed encodings, e.g. (subset of output of file -i *.tex) f1.tex: text/plain; charset=utf-8 f2.tex: text/plain; charset=utf-8 f3.tex: text/x-tex; charset=us-ascii ...
3
votes
3answers
335 views

swapping fields in columns by fixed pattern (yes, no, no, yes)

I want to produce a following list of pages (for imposition work); (number of pages is variable, but I make a sample of my needs using a list of 16 pages, logic is the same for longer lists) 1,16 8,9 ...
4
votes
3answers
3k views

How to list all unique ip address currently connected to a specific port?

Say I want to know how many unique clients are connected to port 5222 on a server. Can you find a way better/faster/stronger than this? netstat -nt | grep ':5222.*ESTABLISHED' | awk '{ print $5 }' \ ...
0
votes
1answer
504 views

Using Awk To Parse Individual Lines

Here is the output from qacct -o Total : OWNER WALLCLOCK UTIME STIME CPU MEMORY IO IOW ...
1
vote
2answers
540 views

How can I delete lines that has an empty first column?

INPUT: CC2352345|m,safnlasndfmnyxdcvyxcvyxcv |klasjdf |3|lasdjflasdf| |2345567356 CC3543353|asdfasdffghntz |klasjdf |3|lsajdfl | ...
4
votes
2answers
503 views

Why does this awk command not play as well with find as sed does?

I am very much a newbie at Unix/Linux command line stuff, and mostly get to where I'm going by copying, pasting, and modifying code I find on the internet. Just mentioning that in hopes people will ...
1
vote
3answers
743 views

Combining Awk with Curl

How would I set my curl statement so that it puts the value of each $3 in for the username, and the value of each $4 for the wallclock information? Some further information I am trying to take the ...
1
vote
1answer
2k views

Use AWK add new line if match exists

I have a file with the following format: aaa@ bbb bbb@ ccc& ddddd@ aaaf ccc@ ddd& eee: abcd& dassda The output should be: aaaa@ bbb bbb@ ccc& ddddd@ aaaf ccc@ ddd& eee@ ...
2
votes
2answers
367 views

Turn a bash and php script into a distributable rpm

I'm semi unix knowledgeable and I want to be able to call down an rpm from my server, run it with something like rpm -i , and have access to the script anywhere. The script is a combination awk and ...
3
votes
2answers
769 views

simple script rotating table

I'm trying to write a simple script, that just rotates csv table. I mean I have some file: head1;head2;head3 field11;field12;field13 and so on. All I want, just to make my file ...
2
votes
2answers
831 views

How to divide a list of values by a number in command line?

I am trying to translate a simple program to the command line using unix utilities. For example, if I have a frequency list (after piping through uniq and sort) 5 x 4 y 1 z I want to print out, ...
8
votes
2answers
177 views

Are there 2 ways to set awk vars via command line?

I noticed an O'Reilly awk example (1997) which assigned an awk variable by setting it on the command line after the program-text. It does work, but I can't find this syntax in man / info awk. Have I ...