Tagged Questions
0
votes
1answer
19 views
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 ...
0
votes
1answer
85 views
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 ...
0
votes
2answers
73 views
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 ...
0
votes
1answer
64 views
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 ...
3
votes
2answers
119 views
Extracting a line section of mysql backup using sed
I occasionally need to extract a single record from a mysqlbackup
To do this, I first extract the single table I want from the backup...
sed -n -e '/CREATE TABLE.*usertext/,/CREATE TABLE/p' ...
2
votes
2answers
94 views
Gathering IP's from a complicated log
I have a question regarding the use of some more advanced grep, awk, sed. I have a log file, for a proprietary MTA, that contains IP's in a string, delimited by [redacted]^~x.x.x.x^[redacted]. So far ...
0
votes
2answers
246 views
Grep to find lines starting at pattern A until pattern B is matched
I have a log that contains bits like this:
[2012-04-16 15:16:43,827: DEBUG/PoolWorker-2] {'feed': {}, 'bozo': 1, 'bozo_exception': URLError(error(110, 'Connection timed out'),), 'entries': []}
...
1
vote
5answers
192 views
Extracting lines from a file based on prefix
I need to extract all lines from file2 that begin with an id # prefix contained in file1.
File 1 is single column like:
324
399
408
135236
321590
File 2 is multi-column like:
1 [tab] 108 [tab] ...
17
votes
7answers
1k views
Can awk be used instead?
I would like to get the number from rating as output from this
# nc localhost 9571
language:
language:en_ZA.UTF-8
language:en_ZW.UTF-8
session-with-name:Ubuntu Classic (No effects):gnome-session ...
2
votes
5answers
155 views
How to remove a certain symbol for a bash script
I have a bash script where I get the disk usage, for example 60%. How can I remove the % symbol? Using grep or awk?
0
votes
3answers
568 views
AWK - Is it possible to search for pattern, then sort results based on a wildcard?
I am storing a number of individually serialized PHP arrays to a file. Each line of the file contains one serialized array. For example:
a:2:{s:4:"name";s:8:"John Doe";s:3:"age";s:2:"20";}
...
1
vote
1answer
194 views
Using Find, Grep, Awk, or Sed To Rename Server After Cloning
My client tells me they have cloned a VM in VMWare of an Ubuntu Linux server. Now it's my job to get into all the files and find out what still has the old server name of "bishop" and change it to ...
1
vote
3answers
140 views
alias to replace a text in file
here is a practical situation.I facing some of my files where there is a common string in these files.I usually will open vi and do some thing like
:%s/text/replacement/g
and I have to do it in ...
15
votes
7answers
23k views
how to find out mac addresses of all machines on network
Is there some easy way to find out mac address of all machines on my network rather than doing an SSH into each and ifconfig | grep HWaddr if there are 300 machines on network I really need some easy ...
1
vote
1answer
300 views
Need help on awk/sed/ perl pattern with regex / grep
Sample file output from grep
file1:my $dbh = DBI->connect("dbi:mysql:$database_name", $DB_USER, $DB_PASSWD)
file2:($dbc,$rc) = mysql_connect($mysql_host,$mysql_user,$mysql_password);
The awk ...
33
votes
11answers
28k views
Do you have any useful awk and grep scripts for parsing apache logs?
I can use log analyzers, but often I need to parse recent web logs to see what's happening at the moment.
I sometimes do things like to figure out top 10 ips that request a certain file
cat foo.log ...