I want to add an attribute to every tag in my xml, which is incrementing using either awk, sed, perl or plain shell cmd
For Eg:
<tag1 key="123">
<tag2 abc="xf d"/>
<tag3 def="d2 32">
</tag3>
</tag1>
I am expecting the following output
<tag1 key="123" order="1">
<tag2 abc="xf d" order="2"/>
<tag3 def="d2 32" order="3">
...
Hi All,
I've been fiddling with TCP/IP networking in Gawk and am having a hard time figuring out why it behaves well with some sites but not for others. I've even tried using HTTP Live Headers in Windows to try and debug what's going on, but to no avail.
The sample Gawk code below (Version 3.1.5) will work fine for the site www.sobell...
I'm trying to run 10 files here.I'm getting the following error. does any one know how to fix it.
It is working fine with <10 files but I need to use it 10 or 50 files.
$ sh skipper.sh file1 filea fileb filec filec fileb filea fileb filec fileb awk: cmd. line:2: (FILENAME=filec FNR=7) fatal: cannot open file `file10' for re ading (No su...
config.status: creating Makefile
awk: ./confYwuPmF/subs.awk:2: S["/; s/!.*/"]=LTLIBOBJS!%!_!# ""
awk: ./confYwuPmF/subs.awk:2: ^ syntax error
awk: ./confYwuPmF/subs.awk:3: S["/; s/!.*/"]=LTLIBOBJS!%!_!# ""
awk: ./confYwuPmF/subs.awk:3: ^ syntax error
awk: ./confYwuPmF/subs.awk:3: S["/...
hi
I write the following awk ( print VAL_1 & VAL_2 if match in file )
awk -v VAL_1=$NET -v VAL_2=$NET_SPEED '$1 == VAL_1 && $2 == VAL_2 ' file
how to add in awk the print command ,
in order to print the word MATCH
if
$1=VAL_1
&
$2=VAL_2
lidia
...
For parsing an invalid XML file, having either unencoded, illegal characters (ampersands in my case):
<url>http://example.com?param1=bad&param2=ampersand</url>
and encoded ones
<description> The good, the bad & the ugly </description>
Please post an example with a sed/awk script that can encode the illegal characters....
I've got a pretty big comma-delimited CSV log file (>50000 rows, let's call it file1.csv) that looks something like this:
field1,field2,MM-DD-YY HH:MM:SS,field4,field5...
...
field1,field2,07-29-10 08:04:22.7,field4,field5...
field1,field2,07-29-10 08:04:24.7,field4,field5...
field1,field2,07-29-10 08:04:26.7,field4,field5...
field1,fie...
Hi,
I have multiple files with hundreds of thousands of records in following format:
2010/08/10 10:07:52|TrainZoom|1393|38797|MyCustomerAPI->,mask = ZPTA,TransId = 1281460071578,testing :-> , capture -> : , IMDB = 9113290830, equipmentName = GMT, technologyName = RMS,,,)|
There are fields separated by pipes and inside...
Hi
I have the following line in a Nagios bash script. It is being used to get the up and down error rates for the specified network cards:
if=`awk -v interface="$INTERFACE" '$1 ~ "^" interface ":" { split($0, a, /: */); $0 = a[2]; print $3 " " $11 }' /proc/net/dev`
I've never worked with awk before today, so I'm finding my way a bit....
I have a file with line: name, space and string of zero and one, and I need to extract every 5nth character of the string of zero and one, make a sum of the results and if the sum is not 0 - save the name into the other file.
1rt2 0001000000100000000000001010000100000000010000001000000100010010000000000000
1gh4 0001000000100000000000001...
I have a text file with a marker somewhere in the middle:
one
two
three
blah-blah *MARKER* blah-blah
four
five
six
...
I just need to split this file in two files, first containing everything before MARKER, and second one containing everything after MARKER. It seems it can be done in one line with awk or sed, I just can't figure out h...
I have never worked on programming languages before.
I am learning C and unix architecture by refering online links.
I got small exercise to write awk script to parse output of ps command.
please help and please provide me the names of best books for C & awk scripting.
...
000 000 000 000 (4 fields each of which is a group of 3 zeros separated by a space)
Process to generate 4 new lines
100 000 000 000
000 100 000 000
000 000 100 000
000 000 000 100
On ea line a group of three zeros is replaced by 100
How can I do this ?
tom
...
I want to substitute a certain filed of the text while keeping the same blank space:
For example, my text is:
Please help me with this problem
Any suggestion or help will be appreciated
Thanks to all who give help
And I want to replace the sentence
"Any ...
I want an awk or sed command to print the word after regexp.
I want to find the WORD after a WORD but not the WORD that looks similar.
The file looks like this:
somethingsomething
X-Windows-Icon=xournal
somethingsomething
Icon=xournal
somethingsomething
somethingsomething
I want "xournal" from the one that say "Icon=xournal"....
As the title say. I need to be able to backup and then recover files.
To make the back up was pretty simple
if [ "$bup" = "true" ]; then
cp $file $file.bak
But to make the recovery.. was not as stright forward.
elif [ "$rup" = "true" ]; then
bak=`find /path/to/file/ | grep .bak`
cp $bak ${bak/\.bak}
fi
It works i...
I have a file containing a list of hexadecimal numbers, as 0x12345678 one per line.
I want to make a calculation on them. For this, I thought of using awk. But if printing an hexadecimal number with awk is easy with the printf function, I haven't find a way to interpret the hexadecimal input other than as text (or 0, conversion to integ...
I'm trying to create AWK script that will filter the input file according to some pattern, and use the strftime() function for some calculations.
($2 ~ /^[HB]/ && $2 ~ /n$/){
print strftime("%Y")
}
The interpreter in use is mawk.
When triggering this script using this command:
awk -f script3 inputFile
I'm getting the error...
Hi All,
I've used regex's in sed before and used a bit of awk, but am unsure of the exact syntax I need here...
I want to do something like:
sed -i 's/restartfreq\([\s]\)*\([0-9]\)*/restartfreq\1$((\2/2))/2/g' \
my_file.conf
where the second match is divided by 2 and then put back in the inline edit.
I've read though that sed ca...
Why do not this work? It finds all the other files but not this one. The only difference is that it has numbers in its name.
awk -F= '$1=="Icon" {print $2}' "/usr/share/applications/hildon/dropn900.desktop"
The file it uses..
[Desktop Entry]
Version=1.0.0
Encoding=UTF-8
Name=DropN900
Comment=Python based DropBox client
Exec=/o...