Questions tagged [awk]

The AWK utility is a data extraction and reporting tool that uses a data-driven scripting language consisting of a set of actions to be taken against textual data (either in files or data streams) for the purpose of producing formatted reports.

The AWK utility is a data extraction and reporting tool that uses a data-driven scripting language consisting of a set of actions to be taken against textual data (either in files or data streams) for the purpose of producing formatted reports. The language used by awk extensively uses the string datatype, associative arrays (that is, arrays indexed by key strings), and regular expressions.

AWK was created at Bell Labs in the 1970s, and its name is derived from the family names of its authors — Alfred Aho, Peter Weinberger, and Brian Kernighan.

194 questions
1
vote
1 answer

Need help on awk/sed/ perl pattern with regex / grep

Sample file output from grep file1:my $dbh = DBI->connect("dbi:mysql:$database_name", $DB_USER, $DB_PASSWD) file2:($dbc,$rc) = mysql_connect($mysql_host,$mysql_user,$mysql_password); The awk pattern should get values databasename, DB_USER And…
1
vote
2 answers

Is it possible to insert data from AWK into MySQL

Can i use mySQL from inside awk code Basically i want the data AWKED in this post into Mysql database
John
1
vote
1 answer

how to exclude folders by date with find?

This is "myfolder": tree -a 'myfolder' myfolder ├── 20220902 │   ├── filefoo │   └── filebar ├── 20221001 │   ├── filefoo │   └── filebar └── 20221015 ├── filefoo ├── filebar └── filexyz etc... my command: find $folder/$(date…
acgbox
  • 376
  • 1
  • 5
  • 21
1
vote
1 answer

awk pattern search with file input to search in another file

I am looking for some hints, how I could achive a better, more elegant, efficient solution. So I've got a file containing a list of names. names.txt: Doe John del Super Mario van Hoppity Jenny van der Hupfburg Susi Smith-Osborne John Marc Desired…
zippy-flop
  • 21
  • 4
1
vote
1 answer

awk $1 and $2 variables coming up empty

GOAL : compare the size of our directory structure day over day. The data folder has over 990tb in it, so I had to run a bunch of parallel du's in order for it to finish in a reasonable amount of time. Occassionally we see large data growth very…
snarfsmojo
  • 11
  • 1
1
vote
1 answer

Misaligned AWK output

I have simple awk command generating output and then sending an email: awk '(NR==FNR){a[$2]=sprintf("%.2f",$1*value); next} {print $1,$2,a[$2]}' OFS="\t\t\t" value=$COST /tmp/1.txt /tmp/2.txt however the last column is misaligned based on the…
DisplayName
  • 145
  • 4
1
vote
1 answer

Format export using grep and awk

I would like to export data from zimbra server, but it's export data in every new lines, my command: zmprov -l gaa -v domain.com | grep -e "zimbraForeignPrincipal: " -e "zimbraTwoFactorAuthEnabled: " -e "^mail: " but the result looks…
zuku
  • 61
  • 1
  • 7
0
votes
2 answers

How do I cut just the file name from from ls -l output?

I am in the process of concatenating ogg audio files in bulk with the help of ffmpeg using a mylist.txt file The format of the mylist.txt file is file '/path/to/file1.wav' file '/path/to/file2.wav' file '/path/to/file3.wav' My 'ls -l' output sample…
Siju George
  • 155
  • 9
0
votes
1 answer

Convert date and time from output

I have a file with date and time on a couple thousand lines. I need to convert: 2019/08/02-01:23:50+0000 To: 02/Aug/2019-01:23:50 +0000 I so far have th=`grep -o '\[.*\]' test.txt | sed 's/\"//g' | head -1 echo…
Ron Russey
  • 128
  • 1
  • 6
0
votes
1 answer

Convert date format in file

I have a file with the current date format 11.22.33.44 - - [2019/08/02-01:23:50+0000] GET www. 1111:2222:3333:4444:5555:6666:7777:8888 - - [2019/08/02-01:28:18+0000] GET www. And i need to convert the format to like below. There are thousands of…
Ron Russey
  • 128
  • 1
  • 6
0
votes
2 answers

sed/awk - find match by one string and change different string on the same line

this should be easy question for most of you but for me. I need to perform some text operations above json a yml config files, which contains definitions of some channels - structure of every line is the same, except variables. What would help mi…
J B
  • 93
  • 9
0
votes
2 answers

Can't redirect awk output to a file... tried everything

I created a nice little command to measure data bandwidth consumption over a metered connection (excluding local traffic): sudo iftop -i enp1s0 -f 'not (src net (10 or 172.16/12 or 192.168/16) and dst net (10 or 172.16/12 or 192.168/16))' -t -L1 2>…
0
votes
1 answer

get a specific line from in linux using grep

Hello I am new to linux and grep and awk commands. I am trying to get the number value from this string variable and then store it in another variable. var1="Version must be incremented on update. Current version is: 532" var2=var1 | grep "?" What…
Alex
  • 172
  • 1
  • 1
  • 8
0
votes
0 answers

chkrootkit awk not found

I am using chkrootkit 0.53 on my ubuntu dekstop 18.04 When I was doing scan with ` ./chkrootkit -p /folder it give me error chkrootkit: can't find 'awk' . Could anyone help? Thank you
rosada
  • 16
  • 3
0
votes
1 answer

nmap output in csv format sorted by last octet in ip address

I have this command which works well to give me a list of ip address, MAC address, and Mac Vendor sudo nmap -sn 192.168.0.0/24 | awk '/Nmap scan report for/{printf $5;}/MAC Address:/{print " "substr($0, index($0,$3)) }' | sort All I want to do is…
William K
  • 1
  • 1