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
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
  • 3
  • 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
  • 503
  • 6
  • 17
  • 36
-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,433
  • 5
  • 31
  • 43
-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
  • 390
  • 4
  • 6
  • 20
-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,433
  • 5
  • 31
  • 43
-1
votes
1 answer

Copy/Move Entire Line To End Of The Line Above

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 preceding line so that it looks like the…
djc72uk
  • 33
  • 1
  • 6
-2
votes
1 answer

How to insert text from a file into another in bash

The content in fileA is: Here’s the ip list. ip: 2.2.3.4 ip: 2.2.3.5 ip: 2.2.3.6 ip: 2.2.3.7 The content is fileB is ip: 1.2.3.4 ip: 1.2.3.5 ip: 1.2.3.6 ip: 1.2.3.7 How to use sed command or other commands in a bash script to produce a list…
Purres
  • 239
  • 1
  • 4
  • 18
-3
votes
1 answer

searching file for last matching line, then put 3rd word of this line into a variable

i have a logfile, a script checks this log-file every hour it shall pack the 3rd word of the last matching line into a variable but i didn't manage it to work yet .. logfile: 2018-11-18 22:27:10 1542576430 c2- restarted=true 2018-11-19 00:14:34…
nyma3
  • 1
  • 2
-3
votes
2 answers

linux + solaris + delete all characters in file except numbers and dot char

please advice how to delete all characters in file except numbers and "." Should be implemented by sed or awk or perl ( one line ) or any other idea , so I will add the syntax in my ksh script remark - the solution must be according to the…
yael
  • 2,433
  • 5
  • 31
  • 43
-3
votes
3 answers

How to pass the output of a command as a variable in a bash script?

I'm trying to pass the output of an awk command as a variable in a bash script, but not having much success so any help is appreciated. homedirectory=$(awk /stephen/ /etc/passwd | awk -F/home/ '{print $2}' | awk -F/downloads '{print $1}') echo…
Stephen
  • 191
  • 1
  • 2
  • 7
1 2 3
12
13