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
24 views

Pass a path with parenthesis and space in system call inside awk script

Inside my simple awk script, I call system command #!/bin/bash Test='/home/software/Other/new (Applet)' ls "${Test}" var=$(ls "${Test}") echo $var awk -vTest="$var" 'BEGIN { ...
0
votes
0answers
8 views

Mac OS X Find and Replace API

Are the Find and Replace operations under the Edit menu in Acrobat or Word simply a front end for the unix awk, sed or grep commands? Where can I find more information about what's going on underneath ...
-1
votes
0answers
15 views

What does cygwin delete when I install new packages?

I would like to install new cygwin packages, however, I obviously want to keep my old ones. I selected the new packages that I wanted to use (gawk, et. al.), and installed again. However, this ...
1
vote
3answers
55 views

How to use grep or awk to save every line from text file as new file?

I am a scripting beginner. What i am trying to do. I have a text file that looks like this (example): hello hi there apple I am trying to make a script that saves every line as a separate new file ...
0
votes
1answer
32 views

need to get average idle time using mpstat

I want to get average idle time of the server using mpstat. The problem I am having is %idle is not in same columns in all the versions of linux. example 1: [root@testserver ~]# mpstat 1 2 Linux ...
0
votes
3answers
43 views

Match the column heading and print the values of the column using awk

I have a data in the file in columns. I want to write a script, which displays the data of the column matching the column heading. C-1 C-2 C-3 C-4 C-5 C-6 C-7 C-8 C-9 10 30 35 20 9 65 87 30 ...
0
votes
1answer
35 views

Monitoring changes in file with bash

I'm running DHCP server on local network which calls this script every few seconds: dumpleases | awk '{print $2}' > leasesnow #get list of all IPs leased in a file, one per line ADDED=`awk ...
2
votes
3answers
49 views

Extract version string from filename

We have a list of filenames in file a.txt with their version string embedded in them. Eg: gson-2.1 xmlParserAPIs-2.4.0 acrobat-1.1 orai18n-mapping-12.1.0.2 jdbc-se2.0 eclipse-core-runtime-20070801 ...
0
votes
1answer
49 views

Using ' (' (space followed by parenthesis) as field separator in awk

In an awk script I am trying to use ' (' as the field separator. However unless I escape the bracket with double back-slash, like this: BEGIN {FS=" \\("} it does not work. If I use FS=" \(" I get ...
0
votes
1answer
49 views

Script shell get id and kill process

Please, i can't find the error in my command. ssh -t root@$machine -x "sshpass -p 'ubuntu' ssh -t root@$address -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/nul -x 'ps -ef | grep ...
0
votes
2answers
51 views

Extending awk one-liner from identifying matching pair of columns (row by row), to multiple columns

I am using Win7 with Cygwin. I have a one-liner that will work for identifying matches in a PAIR of columns, but when I try to introduce additional columns (i.e. >2) I cannot get it to work. So the ...
1
vote
2answers
81 views

Best way to increment numbers in one line in Linux [closed]

I have one line with lot of entries among which is also time. ('DEFAULT',17,NULL,'2014-07-14 10:30:00','Something','2014-07-14 06:30:00',1),('DEFAULT',26,NULL,'2014-07-14 ...
2
votes
2answers
60 views

how to insert text at the beginning of each paragraph in bash

I have a file with multiple paragraphs separated by blank line. Technically they are not paragraphs just sections of text separated by blank line. I want to number the paragraphs so to speak by ...
1
vote
1answer
47 views

Multiple input files and output files in awk

I have a folder full of text files named 000.txt to 181.txt. How can I process all of them (on the command line) with the same awk script (program.awk) and send them to their respective output files ...
1
vote
1answer
51 views

How to parse a space delimited text file

I have a text file like this: Fam1000: CMIN|CMIN_9-RA CMIN|ABC_7-RA GCLA|EFX5.1 GCUC|GCUC_7-RA Fam1001: GCLA|EFX6.1 GCLA|EFX7.1 Fam1002: GCLA|EFX5.1 GCLA|EFX2.1 GCUC|GCUC_8-RA GCUC|GCUC_8-RA Fam1003: ...
0
votes
1answer
34 views

Skip the first 6 lines/rows in a text file with awk

How can I skip the first 6 lines/rows in a text file (input.txt) and process the rest with awk? The format of my awk script (program.awk) is: BEGIN { } { process here } END { } My text file ...
0
votes
2answers
69 views

How to copy file using awk based on time creation to some directory

I trying to copy a file to directory using awk filter based on time creation file #!/bin/bash dir=/home/resaputra23/pyexample/python2/* des=/home/resaputra23/pyexample/backup/ file1= stat $dir | awk ...
1
vote
2answers
56 views

Awk to merge two files using hash

I have two files of the same length, and I want to swap out one files 3 columns with another file's contents. I want to print the following: f1Col1 f1Col2 f1Col3 f1Col4 f1Col5 f1Col6 f2Col1 f2Col2 ...
1
vote
1answer
28 views

How to serach for a line which contains specific string in Bash?

I've got a file which contains some amount of lines, I want to look for a specific string, and if the file contains it, then I want to print a different line from the same file. for example, let's ...
0
votes
0answers
36 views

Multiple replace - using sed or awk

I have a code snippet like below CREATE TABLE TABLE1( ID integer NOT NULL, ROW_CREATED varchar (26) NULL, BATCH_LOG_ID integer NULL, TRANSACTION_TYPE varchar(5) NULL, PARTITION_COL integer ...
1
vote
1answer
19 views

SED/AWK/PERL(GNU userland) - how to substitute pattern A but not pattern B?

First, I am using GNU userland so you can assume I use Bash, GNU coreutils... I have a HTML and I want to change all href="foobarz" into href="" However, I don't want to change any line ...
0
votes
0answers
21 views

Strang, same simple awk script has different results on different machines

This is the strangest mystery ever -- same simple awk script has different results on different machines. The awk script is really simple: $ cat awk_test.awk BEGIN { troubleshoot = 1 } # GET: ...
0
votes
2answers
27 views

list file and using awk to get comment

I want to get the all comment of all files in a folder. And what I have tried is ls -R | awk '/<!--/,/-->/' >> result But it shows nothing in the result file. But if I use the awk ...
0
votes
1answer
47 views

Get the Group name which has GID=0

I wanted to write a shell script in which it needs to give the group name whose GID=0.I used awk command like this, awk -F ':' {$3==0} /etc/group | cut -d ':' -f1 It works fine in redhat,aix.But ...
1
vote
1answer
97 views

piping tail -f into sed or awk

There is another question which is nearly the same, but none of the suggestions from its answer works for me: Piping tail -f into awk I'm trying to tail -f a logfile but want to replace \r with \n ...
0
votes
2answers
30 views

quote-enclosed fields in input to awk

I'm trying to process a webserver logfile in awk. Like 123.222.333.444 - - [24/Feb/2015:13:09:19 +0100] "GET / HTTP/1.1" 200 15852 "https://www.google.dk/" "Mozilla/5.0 (Windows NT 6.1) ...." ...
0
votes
2answers
32 views

Sort on ID, then sort on date, then remove lines which have the older date?

I have a couple of tab delimited files. Each file is structured like so: ID Title Rating Date_Rated What I want to do is merge all these files into one, ...
1
vote
2answers
303 views

bash sed/awk: replace string from a file searching in another file

i have a question about search and replacement on Debian. I have two files. One with: a:b c:d e:f and the other with: e c a` In the second file I want to replace a with b, c with d, e with f. ...
0
votes
0answers
79 views

Copy huge file skipping first line using dd in Linux

I was trying to copy the content of a huge file (10GB) to another skipping the first line (as in head -n1). I tried multiple ways of head, tail, awk and sed. Settled on using tail -n+2 > ./xab.1 ...
0
votes
1answer
42 views

Replace with sed a tag value under a specific section when matching a line

I would like to change a line when another line matchs under a section of a file using the sed command (or awk). Here is an exemple of the file : Extract of MyFic.txt : <PlayList> ... ...
0
votes
3answers
72 views

using awk on only files which START with 'xyz'

I have 3 files in a directory: xyz1.txt, xyz2.txt, rst_xyz.txt and I want to work with ONLY the first two (those which start with xyz). The command ls | awk '/xyz/{print $1}' will return all three of ...
0
votes
2answers
117 views

Unable to get accurate record count of a csv file

I have a .csv file that has some values formatted as paragraphs with line breaks or sometimes bullet points. "STAT","ID","DESC" "UPD", "1", "Updated" "CHG", "2", "Changed" "UPD", "3", "Updated. ...
0
votes
1answer
26 views

How to fetch the string “Hi there” from the below array in unix

I only want to fetch Hi there and store it in a variable VAR1. So basically VAR1 should contain Hi there VIEW_COL[1]="Hi there,USA,Y" This is what i have tried so far. Column_Display_Name=`echo ...
0
votes
3answers
23 views

Filtering 2nd field from a data set and then using uniq on the output

I've got a dataset that goes like this: AAAAA 11111 Data1 AAAAA 11111 Data2 AAAAA 11111 Data3 AAAAA 11112 Data4 AAAAA 11112 Data5 AAAAA 11112 Data6 AAAAA 11112 Data7 AAAAA 11113 Data8 AAAAA 11114 ...
0
votes
2answers
114 views

Text deletion between patterns across multiple lines with respect to text inside pattern

I have a block of text I need to delete, however, only if it contains specific text inside the block: ... <script language="JavaScript"> var somethingA = 0; var somethingB = 0; var ...
1
vote
1answer
75 views

How to Extract Multiple substrings from Log FIle

I am trying to extract the timestamp and the number string in the URL called in an apache logfile that looks like this: 123.456.78.90 - - [16/Dec/2014:06:27:30 +0100] "GET ...
1
vote
1answer
44 views

How to delete the 3rd occurrence of a pattern in a file, and beyond

How can I find the third occurrence of a pattern in a file (Note: not in a line) and delete the line containing the pattern and n lines below that (say, 5 lines below). e.g., COVER fafjasfj isfapifj ...
0
votes
2answers
184 views

ascii value in bash/awk

i have a doubt, i know that with this command, it prints the value of a character based on the Ascii table: printf "%d\n" "'a" ##prints 97 But i wonder how can i make my programm show me the ascii ...
1
vote
1answer
107 views

Using grep, sed or awk to find words in between? I want to be able to extract the package name until .el7

I am writing a script (bash/command-line) and I want to be able to extract the package name until .el7 x=dbus-sharp (an example package name - which changes) example text file: Building ...
1
vote
2answers
47 views

How can I print everything before a match?

After I run hostname I get the FQDN like so: $ hostname foo.mydomain.xyz I'd like to only get the short name foo so I can store it as a variable in a script. I've tried some ways with awk by ...
0
votes
1answer
152 views

Awk script to run a command based on condition using 'if'

I have a piece of code here that basically takes a file called 'srcip' (which is just a list of IP addresses) and compares it to my '~/db' file which is just a tab delimited IP HOSTNAME database of ...
1
vote
2answers
40 views

reverse print without trailing

I have a bash file calling a dns zone and have piped out the fqdn which I need to output in reverse. The snippet below does that fine except I get a trialing . at the end which I don't want creating ...
2
votes
2answers
71 views

Replace Line Breaks on matching lines, using AWK

I have the following data What i'd like to do is for every line, where there is no ,"555" at the end, I want to remove the the line break, \n, and replace it with space. So, the 'matching line' ...
1
vote
1answer
55 views

Get a range of lines from a file and replace a line in that range using awk or sed or both

I would like to replace a line in a section of the smb.conf file using either awk or sed or both if need be. Here's the section in the file... [CMI] oplocks = no wide links = no writeable ...
0
votes
1answer
73 views

Extract text between two slashes and add it at the end of the line after a tab character

I have a text file looking like this: data/CON/001/raw_series_ST_MC_REG_SM.nii data/PAT/001/raw_series_ST_MC_REG_SM.nii I would like to achieve something like this: ...
0
votes
1answer
99 views

word boundary in a awk command not working when printing a range of lines

I am attempting to parse samba .conf file for a specific share section... [CMI] oplocks = no wide links = no writeable = yes delete readonly = yes path = /LOCALSITE/CMI ...
1
vote
1answer
85 views

Script to reference another file first

Hi I have a script and in it I need to get the hostnames from IPs that the script generates. The script will generate those IPs into 1 neat file with only 1 column. It is literally just IP address (1 ...
0
votes
1answer
85 views

How to use the awk to print the output

This command nstats gives me output like below. How can I use awk or grep to give me the uptime with only days on it? I cannot use the "" to get the output. HOSTNAME LOAD MEMORY SWAP PROCS ...
0
votes
1answer
160 views

I'm trying to mirror dns queries generated by TCPDUMP filter and replay them with dig or any other utility

I'm not a very experienced script writer at all. I did find some useful hints in generating an stdout from tcpdump that generates a live feed if you will which is what I want, the problem is handling ...
-1
votes
2answers
50 views

how to split a hex file into two hex files at the first match of certain criteria in perl or just unix scripts

I have a HEX file containing following, I want to split them into two HEX files based on the address: file_in.hex @00000000 00 FC 00 20 89 01 00 00 D9 01 00 00 DB 01 00 00 DD 01 00 00 DF 01 00 00 E1 ...