Skip to main content

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.

1 vote
5 answers
496 views

I have a comma separated line I am using awk to extract fields from. Server1,poweredOn,10.0.18.70,"Blue, Green",POC,Vsphere However, when it comes to the text in double quotes ("Blue, ...
adamtjgogo's user avatar
0 votes
1 answer
108 views

I'm trying to write a script that will read search strings from an input file and then execute a command with $string in the middle of the command line. This is an example of the working command line:...
Drew's user avatar
  • 101
0 votes
2 answers
337 views

I need to display each IBM MQ Queue Manager queue along with its depth. I can do this with a command like echo DISPLAY QLOCAL(QE*) WHERE(CURDEPTH GE 0) | runmqsc QMNAME. The output is similar to this: ...
markfree's user avatar
  • 143
0 votes
2 answers
157 views

I am having an issue in a PHP application, where some processes seem to run for days - still trying to work out how/why but, whilst this happens, the resources on the server get zapped and loads goes ...
bhttoan's user avatar
  • 650
0 votes
1 answer
118 views

I am not an expert with awk tool. I must miss something obvious... What works so far: [root@checkmk ~]# awk '/^[[:blank:]]*SSLCertificateFile/ {gsub(/\/etc\//, "/not_etc/")} 1' \ /etc/httpd/...
gabrielgbs97's user avatar
0 votes
2 answers
665 views

I have a directory that looks like so : /path/to/files/data-file.1 /path/to/files/data-file.2 /path/to/files/data-file.3 /path/to/files/data-file.4 /path/to/files/data-file.5 /path/to/files/data-file....
Ror's user avatar
  • 383
2 votes
3 answers
784 views

I need to filter a row of a csv file by a date. The file is structured as so: [email protected] active 01/24/11 10:04 07/23/23 16:56 ...
dj423's user avatar
  • 23
2 votes
1 answer
615 views

I've seen many more or less related topics, but all I found discuss how to color awk output. I need to preserve the color that was provided as awk input. For example, now I have: ./some_command (...
Putnik's user avatar
  • 2,507
3 votes
1 answer
1k views

I have an ldapsearch query to pull some data of an email system, I am trying to parse the data into something I can analyze in a table/flat file, and generate reports on the accounts. Sample of the ...
dj423's user avatar
  • 53
2 votes
2 answers
356 views

I have the below data (lscpu output) for 1000 servers and I want the same in excel but in row format and not as in command output in columns 1.2.3.4 CHANGED Architecture: ...
Loki's user avatar
  • 21
-1 votes
1 answer
260 views

I have a file that looks like the following: /path/to/a/very/long/path 0 0 0 0 0 0 I need to move the line starting with a number (this can be any value not necessarily 0) to the end of the ...
djc72uk's user avatar
  • 33
4 votes
1 answer
3k views

It isn't clear exactly what more needs to be escaped in the following macro to allow it to be used with awk or sed on FreeBSD. define(`RELAY_MAILER_ARGS', `TCP $h 2525')dnl Here is an awk command ...
Utkonos's user avatar
  • 398
0 votes
1 answer
560 views

I have these strings: Certificate Name: domain1.com Serial Number: 37aadb8fae7b908e1228c3e71 Domains: domain1.com www.domain1.com Expiry Date: 2022-11-20 02:14:29+00:00 (VALID: 3 days) ...
Budianto IP's user avatar
0 votes
0 answers
90 views

I have the below script running successfully manually. But when it is executed in crontab (below), I dont see anything happening. Script #!/usr/bin/gawk -f #!/bin/bash PATH=/usr/local/bin:/usr/bin #...
serverstackqns's user avatar
0 votes
1 answer
208 views

How can I add a variable within awk command? below is my command: cat /home/ubuntu/test/copy.txt | awk 'NR==21{print ".host = "$line";"}1' $line is basically an IP address which ...
serverstackqns's user avatar
0 votes
1 answer
146 views

I've built an SQL migration script that will replace text in a MySQL dump file. Replacements would be easy with sed, but we must account for special serializations (PHP Serialize). The code below ...
Richard Tyler Miles's user avatar
1 vote
1 answer
452 views

This is "myfolder": tree -a 'myfolder' myfolder ├── 20220902 │   ├── filefoo │   └── filebar ├── 20221001 │   ├── filefoo │   └── filebar └── 20221015 ├── filefoo ├── filebar └── ...
acgbox's user avatar
  • 406
1 vote
1 answer
357 views

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 ...
zippy-flop's user avatar
0 votes
1 answer
1k views

I want to get the latets version number from this website: https://www.mailpiler.org/wiki/download so I do a curl to get the content and then just use a pipe to search for the string using grep curl ...
helpmenicely's user avatar
1 vote
1 answer
594 views

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 ...
snarfsmojo's user avatar
0 votes
1 answer
548 views

I'm using a command like this to get some connections from nf_conntrack: awk '($3 == "tcp") && ($6 != "TIME_WAIT") && ($10 == "dport=1234")' /proc/net/...
ihorc's user avatar
  • 53
1 vote
0 answers
1k views

I need to replace a string with the string which is mentioned in a file abcd.txt in all files in a folder. For eg: I want to replace a string 'apple' with whatever the cat output of this file abcd.txt ...
Am3Y's user avatar
  • 77
0 votes
1 answer
734 views

One of my servers has recently been switched to using php-fpm. The error logs now log 404's in a new format: [Sun Dec 26 00:11:37.827426 2021] [proxy_fcgi:error] [pid 25239:tid 140600822003456] [...
steve's user avatar
  • 153
0 votes
1 answer
90 views

Can Linux do conditional judgment to insert the content at a certain line in Linux? For example, I would like to add user "test" to /etc/sudoers to let it can switch to root: 1 # 2 # ...
ITnewbie's user avatar
  • 191
0 votes
1 answer
207 views

I use sed to customize LXC container configuration files from the LXC host. That works well so far. When adjusting comment headers (hostname and date), there are aesthetic problems with the width of ...
questor's user avatar
0 votes
2 answers
477 views

I have a script that is giving me an output like this: ruby-devel is needed by software1 tcl is needed by software 2 python3 is needed by software 3 ocaml is needed by software 1 I'm new to awk but ...
Emersonjr's user avatar
2 votes
1 answer
660 views

I have a text file live below { "data": { "assigned-entity-id": null, "assigned-entity-type": null, "availability-domain": null, "...
Am3Y's user avatar
  • 77
0 votes
1 answer
461 views

I have searched and I don't know what I'm doing wrong but I can't find an answer to this question. I have a file with all text stored as a single line. I am needing to find a pattern and remove all ...
Chris Spangler's user avatar
1 vote
1 answer
180 views

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 ...
DisplayName's user avatar
1 vote
1 answer
197 views

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 "...
Tutek's user avatar
  • 81
0 votes
0 answers
193 views

I have a task to merge three files in linux, so i used awk to achieve this task. hostsfiles is a variable which has test.txt test1.txt and test3.txt awk 1 {{ hostsfiles | join(' ') }} I get below ...
celcoprab's user avatar
0 votes
1 answer
109 views

I have du -sh output saved to txt file: 2.1G /home/x/sample/2GB/ 101M /home/x/sample/100MB/ ... What I want is to multiply each value in the first column by a value taken from variable ...
DisplayName's user avatar
0 votes
1 answer
409 views

So, here's the thing. I have a file contains like this: LOG=123 HEY=BRO FOO=BAR LOG=124 I need the value of LOG= and an output like this: 123 124 I already tried using this command: echo "$LOG&...
Azikun's user avatar
  • 3
0 votes
1 answer
1k views

I am looking to remove all text after the 4 digit year of movie files: Input: Some.Movie.Name.2011.1080p.BluRay.x265.mp4 Another.Movie.Name.1999.1080p.BluRay.x264.mp4 Another.Movie.Name.II.2001.1080p....
Brian Kuepper's user avatar
0 votes
1 answer
251 views

Is there a way I can do a "left outer join" for bash output from 2 different commands based on a common key column (ip address)? For various reasons, I would like to avoid saving the output ...
louis xie's user avatar
  • 125
0 votes
1 answer
422 views

I have a change I need to make across multiple different sites and may need to make again in the future, so I'd like to put it in a shell script. Essentially I want to find a specific class block in a ...
TBridges42's user avatar
0 votes
2 answers
426 views

nethogs is a linux process bandwidth monitoring tool. https://github.com/raboof/nethogs nethogs -t it's output looks like this. Refreshing: sshd: root@pts/0/4002/0 0.185156 0.0773437 unknown ...
The Unix Janitor's user avatar
0 votes
1 answer
2k views

What I got as extra variable to ansible playbook is "CHOW_app/timmy_app1/johnn_app3/harper_app4/mona_app5". This is passed as single variable to the playbook. I have to separate it and save it in a ...
saffron's user avatar
  • 173
0 votes
1 answer
118 views

I have a little question. I have a list of processes. After this command ps aux | grep postgres I see postgres 1178 0.0 0.2 320064 27060 ? S Apr12 0:05 /usr/lib/postgresql/10/bin/...
Piduna's user avatar
  • 591
0 votes
2 answers
6k views

Can someone explain me what happens here? uptime | awk -F: '{print $NF}' -F: field separator $NF: number of fields in the current line I don't understand why this command result in the same result as ...
Mike's user avatar
  • 103
0 votes
2 answers
979 views

I have a column based .txt file and I want to grep output the Common Name, having a little trouble. V 300223164711Z 01 unknown /C=UK/O=LMG/OU=server/CN=server/name=server/emailAddress=...
Kam-ALIEN's user avatar
0 votes
1 answer
310 views

We have multiple servers and i would like to print users list and access level using bash. I tried below command but could not get exact result what i wanted to: awk '/Allow root/{p=5} p > 0 {...
Santosh Garole's user avatar
0 votes
2 answers
2k views

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' ...
Siju George's user avatar
0 votes
1 answer
373 views

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 -...
Ron Russey's user avatar
0 votes
1 answer
284 views

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 ...
Ron Russey's user avatar
3 votes
3 answers
4k views

I'm trying to figure out how I can get the network interface name and then change the name. Right now it's easy to change the name with this example: ip link set eth1 name <newName>; However I ...
Speedy059's user avatar
  • 133
8 votes
2 answers
30k views

i have ssh-key, something like this -----BEGIN RSA PRIVATE KEY----- my_super_secret_password -----END RSA PRIVATE KEY----- Of course this key does not work. When i am doing manual things, something, ...
Piduna's user avatar
  • 591
3 votes
2 answers
3k views

I have many .txt files with their filenames being different dates: 01.01.2010.txt 02.01.2010.txt ... Currently each file (e.g.: 01.01.2010.txt) looks like this: 0.351 XXX XXX XXX XXX 0.292 ...
user3200534's user avatar
0 votes
2 answers
531 views

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 ...
J B's user avatar
  • 93
0 votes
2 answers
1k views

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 ...
Achis K's user avatar