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
0
votes
1 answer

Finding out total PHP usage in MB's

I'm trying to find out total memory used by all PHP processes on my CentOS server. After some grepping and awking this is my final command. ps -e | grep php | awk '{print $1}' | xargs pmap | grep total | awk '{print $2}' | sed 's/K//' | awk '{SUM +=…
jfreak53
  • 163
  • 1
  • 4
  • 27
0
votes
4 answers

Move files to subdirectories: /img/ab123.jpg --> /img/ab/ab123.jpg

I have a linux webserver with about 25.000 images in one directory. They are all lowercase and in the format two letters, three digits and jpg as the extension. Because that many files in one folder is getting difficult to manage I want to move them…
user168080
  • 41
  • 2
0
votes
1 answer

Need equivalent of command with nmap, awk and grep for Windows machines with PowerShell and/or Perl

Please see this thread for reference How can I scan using nmap and Zenmap all hostnames that begin with a particular string? One of the answers in the thread above uses the following query (I take no credit at all for the command): nmap -sL -oG -…
user717236
  • 265
  • 1
  • 4
  • 17
0
votes
1 answer

Regex matching specific details if first match exists, multiline

I'm struggling to get the correct regex to match specifically 'Contact' and 'User-Agent' only if the 'Contact' address matches 10.0.x.x in ~70GB of SIP messages. The SIP message will always contain a 'Contact' and 'User-Agent' however these could be…
Luke B
  • 101
  • 1
0
votes
2 answers

remove non-printing characters

I have a tab delimited text file. When I open the file with vi editor, I can see ^M character (in blue color). This is not part of my data. It got there because the original SQL data had carriage return /r sign. 713498 29195 NWSO NE SA COLLEGE…
shantanuo
  • 3,579
  • 8
  • 49
  • 66
0
votes
1 answer

grep + match value only if value in the end of line

please advice what is wrong with my code, ( I run this code on both OS linux and solaris ) I don't get the line from: "file ended with .tmp" example: I need to verify if $FILE ended with .tmp or .old etc ... code with the following example set…
yael
  • 2,433
  • 5
  • 31
  • 43
0
votes
3 answers

Remove a sentence which starts with word "mark" and ends with ";"

I am having 100's of files that contain sentence that starts with mark and ends with semicolon(;). eg: mark is driving a car; i need to remove every sentence starts with mark and end with ";" How to do this using sed or simmilar tools. i have…
ananthan
  • 1,510
  • 1
  • 18
  • 28
0
votes
1 answer

Remove all words that DOESN'T contain a colon

I have a file with this type of lines: blabla bla:bla whatever what:ever alpha bravo charlie del:ta I only want to keep the words that contain a colon. So the output for the above would be: bla:bla what:ever del:ta Does anyone have any ideas?
miono
  • 546
  • 2
  • 6
0
votes
2 answers

linux + create host file from CSV file by sed or awk or perl

I have the following CSV file this file defined which Linux machine exist in the system and there ip's my target is to create host file from this file please advice how to create host file as example 1 from my CSV file ( I need to match the IP…
yael
  • 2,433
  • 5
  • 31
  • 43
0
votes
3 answers

How to join a variable number of lines

I have a file with Feature names and a variable number of usernames below: Feature1 user1 user2 Feature2 user3 I'd like to be able to move the usernames to the same line as the Feature name (along the lines of the vi join command). The Feature…
0
votes
1 answer

cutting relevant portions of a file

I want to cut some portions of binary file starting from a particular pattern and ending at a particular pattern.How do I do that in linux using bash.Can this be done using sed or awk? I have a file like given below. bd=0x422e90e0ff4abc00 …
liv2hak
  • 303
  • 4
  • 13
  • 25
0
votes
3 answers

shell script + match MAJOR and CRITICAL strings from log file

I need to match lines that have MAJOR and CRITICAL strings that comes after the word ERROR:< any integer number > please advice how to do that with one awk or sed command? more HW_Log.txt CHK_HW ERROR:0 INFO self_monitor …
Eytan
  • 611
  • 6
  • 13
  • 27
0
votes
1 answer

Sanitizing dates using sed or awk on an ldapsearch query

I'd like to pipe the output of an ldapsearch to sanitize the dates returned - I presume sed and/or awk can help with this but would appreciate a bit of help. The fixed length date format in the LDIF output file is like this: whenCreated:…
Linker3000
  • 668
  • 1
  • 5
  • 14
0
votes
1 answer

Parse value of $DatabasePassword from RT_SiteConfig.pm

I'm writing a Bash shell script to backup our Request Tracker (RT) MySQL database on a daily basis. Instead of hard-coding the MySQL database user's password in the shell script I'd like to parse it from RT's RT_SiteConfig.pm file. The relevant line…
Xhantar
  • 1,042
  • 1
  • 8
  • 11
0
votes
3 answers

Parsing a diff file using grep/awk

I'm trying to parse a standard diff of some sql files to return only the delete sections. I have been using grep with the after context (-A) which almost works (only because I know that delete sections will all be very short). e.g. diff $$_$1.sql…
Robert
  • 133
  • 1
  • 7