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
7
votes
2 answers

bash sub-string extraction for specified start and end character

For example I have a log file having this entry: [Wed Aug 08 11:39:41 2012] [error] [client 155.94.70.224] ModSecurity: [file "/etc/httpd/modsecurity.d/rules/base_rules/modsecurity_crs_20_protocol_violations.conf"] [line "271"] [id "960020"] [rev…
Farhan
  • 4,269
  • 11
  • 49
  • 80
6
votes
2 answers

How to make in SSH private key from one line, three lines

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, like this -----BEGIN RSA PRIVATE KEY-----…
Piduna
  • 541
  • 4
  • 12
  • 25
6
votes
1 answer

File size limit exceeded in bash

I have tried this shell script on a SUSE 10 server, kernel 2.6.16.60, ext3 filesystem the script has problem like this: cat file | awk '{print $1" "$2" "$3}' | sort -n > result the file's size is about 3.2G, and I get such error message: File size…
yboren
  • 61
  • 2
6
votes
3 answers

AWK and file names with space in it.

I'm trying to parse files with awk to change their names. Everything went well until im started to do this with files with space in file name. File names are something like 11237_712312955_2012-01-04 18_31_03.wav and I want to replace wav from file…
B14D3
  • 5,188
  • 15
  • 64
  • 83
5
votes
2 answers

Split large log file WITHOUT keeping the original (splitting in-place)

I have a 226GB log file, and I want to split it up into chunks for easier xzing. Problem is I only have 177GB of space left in my workable space. Is there a way to split a file in half or into N number of chunks without keeping an additional copy…
Ceafin
  • 61
  • 1
  • 4
5
votes
3 answers

Puppet & Facter - how to determine if running Cent 6 or Cent 5

How would you use facter and puppet to determine if the OS is running Cent 6.x or Cent 5.x ? facter operatingsystemrelease 6.4 I only care about the major release (6) I've thought about using awk, but there must be a better way that is more…
spuder
  • 1,725
  • 3
  • 26
  • 42
5
votes
4 answers

What command can I use to search sendmail logs for ALL message details involving a specific recipient.

CENTOS 5.x | Sendmail Occasionally I need to search through sendmail delivery logs to find out what happened to a missing message. This usually involves two (or more) steps: STEP 1: Search /var/log/maillog for the user's email address. For…
Mike B
  • 11,871
  • 42
  • 107
  • 168
5
votes
3 answers

Color awk output on commandline?

When i process a logfile in awk, is there a possibility to colorize the output on commandline?
NES
  • 215
  • 2
  • 8
5
votes
2 answers

Perl search & replace

How can I use search and replace to change the contents of a file. I need to be able to change the 'all to none' and/or 'none to all' without having to manually do it every time for hundreds of lines. below is a sample text file with lines numbers…
user36101
  • 53
  • 3
4
votes
2 answers

How to show specific luns from lsscsi command?

I need to grep specific luns from the lsscsi command. For example: [root@e15l1 ~]# lsscsi 4 0 1 | awk '{print $1,$6}' | head [4:0:1:0] - [4:0:1:1] /dev/sdab [4:0:1:2] /dev/sdj [4:0:1:3] /dev/sdz [4:0:1:4] /dev/sdk [4:0:1:12] /dev/sdo [4:0:1:13]…
igor
  • 141
  • 1
4
votes
3 answers

Determine number of unique lines with awk or similar in bash

I am using AWK to read through a custom log file I have. The format is something like this: [12:08:00 +0000] 192.168.2.3 98374 "CONNECT 192.168.2.4:8091 HTTP/1.0" 200 Right now, I have AWK (from bash) set to read the whole log, analyze each line…
4
votes
3 answers

awk on vmstat to get si,so

I am writing a shell script to check the vmstat si and so data at various time intervals vmstat 1 sample output: procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu---- r b swpd free buff cache si so bi bo …
APZ
  • 954
  • 2
  • 12
  • 25
4
votes
2 answers

Multiline data list (ldif file) manipulation with awk or other tool

I'm trying to manipulate an ldif file with multiple entries. My purpose is to parse this existing ldif file, extracting the "givenName" and "sn" attributes, so to generate a "mail" attribute. I was thinking about AWK or Sed, but unfortunately I'm…
spidernik84
  • 319
  • 1
  • 5
  • 12
4
votes
1 answer

Unexpected Awk results with sh -c

I am trying to sudo a command that uses Awk, and it looks like awk works differently inside sh -c. echo '1 2' | awk '{print $2}' 2 sh -c "echo '1 2' | awk '{print $2}'" 1 2 Why is this happening?
Michael Sofaer
  • 143
  • 1
  • 3
3
votes
3 answers

CentOS 7 how to get interface name by macaddress?

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 ; However I want to have a script or command where I have it auto…
Speedy059
  • 133
  • 2
  • 5
1
2
3
12 13