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.

184 questions
0
votes
1 answer

How to separate variables using awk and append it to Text file using ansible

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 text file in this format. REVOKE CHOW app REVOKE…
saffron
  • 123
  • 1
  • 3
  • 9
0
votes
1 answer

How to grep lines only with matched words in Linux

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/postgres -D /var/lib/postgresql/10/main -c…
Piduna
  • 501
  • 3
  • 10
  • 23
0
votes
2 answers

uptime | awk -F: '{print $NF}' - What happens here?

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 uptime | awk -F: '{print $5}'
Mike
  • 103
  • 5
0
votes
2 answers

Extract string from column with grep

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=support@kam.org V 300223170002Z 02 unknown…
Kam-ALIEN
  • 19
  • 5
0
votes
1 answer

How to print only Users list and Access level from /etc/sudoers?

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 {print $1; p--}' /etc/sudoers above command just give…
Santosh Garole
  • 383
  • 2
  • 11
-1
votes
1 answer

How to pass variable into bash script and use seperate variables with awk?

I have a script that I am using to clear out all lines of a log files older than X days. X can be passed in via command line as well as the log file name, ex usage: ./purge-catalina.sh 3 /opt/tomcat8/logs/catalina.out The script itself looks like…
ninjasense
  • 141
  • 1
  • 6
-1
votes
1 answer

validate file content with bash Regular Expressions + Linux

how to validate the following file content that should be include single integer/float number by bash Regular Expression or any other idea with awk/sed cat /var/VERSION/Version_F35_project_usa 2.8
jango
  • 59
  • 2
  • 2
  • 12
-1
votes
1 answer

how do i remove local ip from list of ip addresses?

I have a variable that contains list of ips and i will like to remove the ip of the instance where the variable is set Please see below [root@ip-10-10-2-100 ~]# INSTANCE_IP=$(curl -s…
uberrebu
  • 493
  • 5
  • 15
  • 32
-1
votes
1 answer

How to use the awk,sed Modify the text?

As follows, some text 16G 16G 1.9G 40G 4G 4G 952M 60G 16G 16G 1.6G 40G 5G 780M 5G 80G I want to change all the unit from 'M' to 'G', like this 16G 16G 1.9G 40G 4G 4G 0.92G 60G 16G 16G …
jython.li
  • 84
  • 2
  • 10
-1
votes
1 answer

use awk to execute logrotate command when disk is full

What I'm trying to do is manually run logrotate when my disk is greater than 90% full. I'm trying to do this using df -P and awk. I can get it to display the percentage, if it's > 90, but I can't quite figure out how to get awk to run logrotate -f…
-1
votes
2 answers

How to find DEVICE on which read per second (rd_sec/s) is highest?

I am using awk to find out DEVICE on which read per second (rd_sec/s) is highest, (from SAR file) below is my command : # sar -d -f sa28 | awk '{print $3,$4}' |sort -k1,1n Output is showing on console with sorted manner, But I want the exact one…
Vin
  • 51
  • 1
  • 6
-1
votes
2 answers

linux/solaris insert date & time at the beginning of each line in file

I want to add date & time at the begging of each line in some file I used sed in order to add the date & time before each line in file please advice what I need to update in my sed in order to support this action , I can accept other solution with…
yael
  • 2,363
  • 4
  • 28
  • 41
-1
votes
1 answer

filter body of incoming email in procmail

I've encountered some problem when configuring my linux machine. We are configuring fetchmail and procmail in order to receive the email from the external mail server.The problem start when we want to get the body content of the email by using…
user119720
  • 380
  • 3
  • 6
  • 19
-1
votes
3 answers

linux + generate new file with specific structure from text file what the best option

in my Linux machine I have the file orig-file.txt this file include now 4 fields but they could be less or more ( this file generate by other application ) I need advice - what the best option to translate the orig-file.txt to file as…
yael
  • 2,363
  • 4
  • 28
  • 41
-1
votes
1 answer

How to remove text after a 4 digit year in a file name

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.BluRay.x264.mp4 Desired…
1 2 3
12
13