BEGIN{
q = "\""
FS = OFS = q ", " q
}
{ split($1, arr, ": " q)
for(i in arr ){
if(arr[i] == "name"){
gsub(q, "'", arr[i+1])
# print arr[1] ": " q arr[2], $2, $3
}
}
}
a json file have some data like this:
{"last_modified": {"type": "/type/datetime", "value": "2008-04-01T03:28:50.625462"}, "type": {"key": "/type...
Hi
I have a file with records that are of the form:
SMS-MT-FSM-DEL-REP
country: IN
1280363645.979354_PFS_1_1887728354
SMS-MT-FSM-DEL-REP
country: IN
1280363645.729309_PFS_1_1084296392
SMS-MO-FSM
country: IR
1280105721.484103_PFM_1_1187616097
SMS-MO-FSM
country: MO
1280105721.461090_PFM_1_882824215
This lends itself to parsing via a...
hi...
how to change number format
from XXXXXX.XXX to XXXXXX,XXX
using sed
thaks
...
Hi,
I've got something like that:
xinput --list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Microsoft Basic Optical Mouse id=8 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master...
Hi,
I am monitoring a log file by doing "TAIL -n -0 -F filename". But this is taking up a lof of CPU as there are many messages being written to the logfile. Is there a way, I can open a file and read new/few entries and close it and repeat it every 5 second interval? So that I don't need to keep following the file? How can I remember t...
I want to find a pattern which is nearest to a specific pattern. Such as I want to print "bbb=" which is under the "yyyy:" (it is the closest line with bbb= to yyyy). It is line 8. line numbers and the order might be changed so it is better not to use line numbers.
root# vi a
"a" 15 lines
1 ## xxxx:
2 aaa=3
3 bbb=4
4 ccc=2
...
Hi - I have one text file (fileA), approx 200 lines, each line with the format
afield1 afield2 afield3 afield4 afield5
and another text file (fileB), approx 300 lines, same format
bfield1 bfield2 bfield3 bfield4 bfield5
I want to create another text file, where if afield1 & bfield1 match, it writes a line like:
"some text" bfield4...
So I need to convert a date to a different format. With a bash pipeline, I'm taking the date from the last console login, and pulling the relevant bits out with awk, like so:
last $USER | grep console | head -1 | awk '{print $4, $5}'
Which outputs: Aug 08
($4=Aug $5=08, in this case.)
Now, I want to take 'Aug 08' and put it into a d...
I am using
awk '{ printf "%s", $3 }'
to extract some field from a space delimited line. Of course I get partial results when the field is quoted with free spaces inside. May any body suggest a solution please?
...
I want to extract the variable # of digits between two patterns, eg:
correction:
blah blah.... AAM #6,blah blah
blah blah.... AAM #10 , blah blah
blah blah.... AAM #100 , blah blah
output: 6, 10 and 100
I need to extract numbers between "AMA #" and comma
...
I have a large number of image files that i need to rename from the comand line. I believe the best way to do this is to use awk (please correct if this is incorrect).
file names are like the following
1038282829128738912-1.jpg
Every image file starts with '103' and I want to replace this part of the file name with '201003' - leaving...
The corrupt table entry is logged in the error file something like this...
/usr/local/mysql/bin/mysqld: Incorrect
key file for table
'./accounts/headers.MYI'; try to
repair it
I want to write a query that will repair this table.
REPAIR TABLE accounts.headers;
What I need to do is search for the first instance of "./" an...
Given a tabbed delimited text file with two columns "name" and "date":
Sam 20100101
Sam 20100101
Sam 20100102
George 20100101
George 20100101
George 20100102
Can I use awk to add third column with a partitioned running total, such as starting a counter at 0 for each distinct pattern of column one and two then increment...
My SQL query looks like this...
sekect * FROM mail_headers a LEFT JOIN
mail_headers_body b ON a.mailid=b.id
blah blah blah
I can select the lines before and after the result, using -A, -B switches. But how do I find the 4 words before and after the selected text?
grep -i 'JOIN mail_headers_body' mysql-gen.log
This will retur...
I often need to kill a process during programming.
The way I do it now is:
[~]$ ps aux | grep 'python csp_build.py'
user 5124 1.0 0.3 214588 13852 pts/4 Sl+ 11:19 0:00 python csp_build.py
user 5373 0.0 0.0 8096 960 pts/6 S+ 11:20 0:00 grep python csp_build.py
[~]$ kill 5124
How can I extract the process id ...
I have the following XML output when I grep for "Server":
<Server id="1" src="/other/Server/PRX01/PRX01.xml"/>
<Server id="2" src="/other/Server/PRX01/PRX02.xml"/>
<Server id="3" src="/other/Server/PRX01/PRX03.xml"/>
<Server id="4" src="/other/Server/PRX01/PRX04.xml"/>
I need to be able to take this output and sed/awk or some other to...
Here is an example of the type of data that I am trying to manipulate:
1213954013615]: 992
1213954013615]: 993
1213954013615]: 994
1213954013615]: 995
1213954013615]: 995
1213954013615]: 996
1213954013615]: 996
1213954013615]: 996
1213954013615]: 998
1213954247424]: 100
1213954247424]: 1002
1213954247424]: 1007
1213954303390]: 111
12139...
Hello, I have many large (~30 MB a piece) tab-delimited text files with variable-width lines. I want to extract the 2nd field from the nth (here, n=4) and next-to-last line (the last line is empty). I can get them separately using awk:
awk 'NR==4{print $2}' filename.dat
and (I don't comprehend this entirely but)
awk '{y=x "\n" $2};EN...
My HTML code has the following line.
<TH>column1</TH><TH>column2</TH><TH>column3</TH>
Can I use sed tool to replace the column1 with "Name", column2 with "Surname" ...
<TH>Name</TH><TH>Surname</TH><TH>City</TH>
I have the list of the columns in a echo statement of my shell script.
echo 'Name, Surname, City'
These 3 values needs ...
How do I extract text in between strings with very specific pattern from a file full of these lines? Ex:
input:a_log.gz:make=BMW&year=2000&owner=Peter
I want to essentially capture the part make=BMW&year=2000. I know for a fact that the line can start out as "input:(any number of characters).gz:" and end with "owner=Peter"
...