Hi,
In following code I am trying to pass shell varibale to awk. But when I try to run it as a.sh foo_bar the output printed is "foo is not declared" and when I run it as a.sh bar_bar the output printed is " foo is declared" . Is there a bug in awk or I am doing something wrong here?
I am using gawk-3.0.3.
#!/bin/awk
model=$1
awk...
Dear all,
I read about sed last week and now, I do some extraction from a file using sed, that is fine,
Now, I would like to change the data in the first column to the line number say
1 3 3 0 0 0 1 3 35 34
16 3 3 0 0 0 34 35 33 19
31 3 3 0 0 0 19 33 71 68
46 3 3 0 0 0 68 71 72 69
61 3 3 0 0 0 69 72 73 70
76 3 3 0 0 0 70 73 67 53
and...
I've got a particular situation where I need to remove the operations of a series of commits in Subversion repository. Entire contents of (/trunk /tags /branches) were tagged and subsequently removed when the mistake was realized. I would simply use svndumpfilter to remove the offending nodes, but someone re-used the bad tag name at a la...
I want to append something at the end of a certain line(have some given character).
For example, the text is:
Line1: I just want to make clear of the problem
Line2: Thanks to all who look into my problem
Line3: How to solve the problem?
Line4: Thanks to all.
Then I want to add "Please help me" at the end of
Line2: Thanks to all...
Hi All,
Been wondering if this is doable in AWK for some time but always worked around it in the past.
Below I initialize an array with 3 months of the year... for readability I ommited the other 9 months. These months are then used in the if-statement as part of a regular expression, but AWK doesn't like it. I can't seem to find any...
I have a cshell script that is something like this:
`netstat -ap | & grep tcp | grep myprocess | awk '{print $4}' | awk 'BEGIN { FS = :"}{print $2}'`
This is how it works
1.
$ netstat -ap | & grep tcp | grep myprocess
tcp 0 0 *:1234 *:* LISTEN 8888/myprocess
2.
$ netstat -ap | & grep tcp | grep myprocess | ...
hi
I
write the following syntax (part of my ksh script)
to check if the first word of LINE=star
and the second word is car
[[ ` echo $LINE | awk '{print $1}' ` = star ]] && [[ ` echo $LINE | awk '{print $2}' ` = car ]] && print "match"
I need other simple smart and shorter solution then my syntax.
from awk,perl or sed(if ...
I have the following sed command. I need to execute the below command in single line
cat File | sed -n '
/NetworkName/ {
N
/\n.*ims3/ p
}' | sed -n 1p | awk -F"=" '{print $2}'
I need to execute the above command in single line. can anyone please help.
Assume that the contents of the File is
System.DomainName=shayam
System.Add...
I want to sort the words on lines in a file line by line and I want the ouptut to be lines with the words sorted alphabetically.
for example:
queue list word letter gum
another line of example words
...
I want the output to be:
gum letter list queue word
another example line of words
...
I can't seem to get it to wo...
hi all
I need to verify if the second word from $line_from_file is a string with lowercase or uppercase characters
(WORD - string can be with numbers)
How to match WORD string? (I use this syntax in ksh script)
[[ ` echo $line_from_file | awk '{print $2}' ` = WORD ]] && print "MATCH"
WORD - can be small or capital chara...
I saved a value by shell command:
For example:
timeoutvalue=`echo "timeout=2.0"`
And I have to grep the value of timeout from another text, and replace it with this timeoutvalue.
For example, the text is egtest:
<host ip="255.255.255.0" name="testhost" description="hostfortest" connection="xmlrpc" timeout=4.0/>
I want to grep the v...
I have to extract a parameter from a configuration file, and replace its values with another given value.
The config file is:
<host ip="200.200.200.200" name="testhost" description="test server" type="TEST_Duplex " connection="xmlrpc" xmldefaulttimeout="2.0" xmlspecifictimeout ="8.0"/>
I have to replace the value of xmldefaulttimeout=...
Hi,
I am having a file that has the following lines say
13:26:35.655029 (TN) sh:sdf:sdf > ra:ram:raml, type Normal (800), length 21: ID 10.1.1.1 > 20.2.2.2: Addr 77: TP
13:26:35.656029 (TN) ra:ram:raml > sh:sdf:sdf, type Normal (800), length 21: ID 20.2.2.2 >10.1.1.1: Addr 77: TP
I need to get sh:sdf:sdf , ra:ram:raml ,10.1.1.1 , ...
Hi
I have a file of events that has multiple multi lined events between <event> and </event> tags. I want to print out the entire event From <event> to </event> only if a line within that event contains either the string uniqueId="1279939300.862594_PFM_1_1912320699" or uniqueId="1281686522.353435_PFM_1_988171542". The file has 100000 eve...
Hi
I am figuring out the Ipython shell support. Its seems awk doesn't work i.e
following command
!ls -l | awk '{print $1}'
just prints "1".
How do I pass the "$" sign correctly to shell. I am using zsh.
Thanks
Sandeep
...
Hello everyone, Ive been trying to sort out output using AWK, and have been pretty successful going through some of the stuff on stack overflow until i hit the last part of the command below.
-bash-3.2$ find /home/username/www/devdir -mindepth 2 -maxdepth 2 -type d -printf "%TY %Tm %Tb %Td,%TH:%TM,%p,\n" | grep "^$r" | grep Aug | sort -...
I have collected vmstat data in a file . It gives details about free, buffer and cache .
SInce i'm interested in finding the memory usage , I should do the following computation for each line of vmstat output -- USED=TOTAL - (FREE+BUFFER+CACHE) where TOTAL is the total RAM memory and USED is the instantaneous memory value.
TOTAL memory ...
I am making a bash script where I want to find files that are equal to a variable. The equals will then be used.
I want to use "mogrify" to shrink a couple of image files that have the same name as the ones i gather from a list (similar to "dpkg -l"). It is not "dpkg -l" I am using but it is similar. My problem is that it prints all the...
hi
from my ksh I have
[[ ` echo $READ_LINE | awk '{print $2}' ` != SOME_WORD ]] && print "not match"
can I get suggestion how to verify the same without echo command? ( maybe awk/sed is fine for this? )
lidia
...
Is there a way to filter lines with awk using the column (not field) number? I want to grab all the lines in a text file containing the value of field 6 which is assigned to a variable. I am using:
awk -v temp=${het} '{if $6 == temp} print $0}'
But I have noticed that very occasionally field 5 is blank which messes things up. Wh...