|
Dear all,
I have no problem using the following command of AWK as a stand alone command, without any error:
$ awk '$9 != "NTM" && $9 != ""' myfile.txt | less -Sn
But when I apply them inside Perl's script for qsub (i.e. running job in linux cluster) command...
Started by neversaint on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
The following script....
They're being parsed by Perl itself.
And $nn to be interpreted by Perl, the actual line should be:
awk '\$9 != "NTM" && \$9 !=""' $file >Putting a "\" character before all of your "$9" variables will fix it.
|
|
I have an XML file with the following line:
<VALUE DECIMAL_VALUE="0.2725" UNIT_TYPE="percent"/>
I would like to increment this value by .04 and keep the format of the XML in place. I know this is possible with a Perl or awk script, but I am having...
Started by DC on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
If your XML file is produced in a predictable way something... .
That said.
Check this DOM Processing with Perl article out.
For a Perl solution I'd go for using the DOM.
With the xsltproc command in place I would suggest you use XSLT for this .
|
|
I want to scan the passwd file and change the order of words in the comment field from firstname lastname to lastname firstname , and force the surname to capitals.
So, change every line from:
jbloggs:x:9999:99:Joe Bloggs:/home/jbloggs:/bin/ksh
to:
jbloggs...
Started by paul44 on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
" $first"; print join(':', @tokens), "\n"; }
$ awk -F":" ' { split($5,a/ksh
$ awk -v FS=":" '{split($5, a, " "); name = toupper(a[2]) " " a[1]; gsub($5, name); print $0}' passwd
Won't work if you have middle....
]; $tokens[4] = uc($last).
|
Ask your Facebook Friends
|
Let's say I have something like this (this is only an example, actual request will be different: I loaded StackOverflow with LiveHTTPHeaders enabled to have some samples to work on):
http://stackoverflow.com/ GET / HTTP/1.1 Host: stackoverflow.com User...
Started by Tim on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
In Perl:
local $/ = "\n\n"; while (<>) { print if /^(?:GET|POST)/; # Add more request types with the format of the output of LiveHTTPHeaders, you should use something like the following:
#!/usr/bin/perl+!!gm; print; }
I consider using....
|
|
I have an input file say, such as:
a=1 b=2 c=3 d=4 a=2 b=3 a=0 c=7 a=3 b=9 c=0 d=5 a=4 d=1 c=9
Assume that the order of column names (a,b, c and d) remains the same. How do I write a script/ command which will help me extract values specific to columns...
Started by Sumit on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
#!/usr/bin/perl use strict; use warnings; while ( <DATA> ) { if( my @cols c=0 d=5 a=4 d=1 c=9
Output:
C:\Temp....
Liner version:
$ perl -lpe '@x=/([bd]=[0-9])/g; $_="@x"' test.txt
m//g in list context returns all the matches as a list.
|
|
I want to extract the URL from within the anchor tags of an html file. This needs to be done in BASH using SED/AWK. No perl please.
What is the easiest way to do this?
Thanks a lot.
Started by codaddict on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
An example, since you didn't provide any sample
awk 'BEGIN{ RS="</a>" IGNORECASE=1 } { for(o.
|
|
Hey guys,
I'm having some issues escaping Quote: s and getting the following line to run in perl . The Quote: s are really messing me up.
Code: system (" awk 'BEGIN{FS="/t";OFS=","} {print \$1,$fieldNum}' $file > output.csv ");
Started by WongSifu on
, 2 posts
by 2 people.
Answer Snippets (Read the full thread at unix):
|
|
I find AWK really useful. Here is a one liner I put together to manipulate data.
ls | awk '{ print "awk " "'"'"'" " {print $1,$2,$3} " "'"'"'" " " $1 ".old_ext > " $1 ".new_ext" }' > file.csh
I used this AWK to make a script file that would rename...
Started by Alex on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
Ls -1 *.mp3 | ....
He also could use instead of mv ...
He called it "awf".
Claimed that if Larry Wall had known how powerful awk was, he wouldn't have needed to invent perlHenry Spencer wrote a fairly good implementation of nroff on awk.
|
|
The following command on my Mac (10.6) gives me an undefined function error:
$ awk 'BEGIN{now=strftime("%D", systime()); print now}' awk: calling undefined function strftime source line number 1
On a Red Hat system, I get the expected result:
$ awk 'BEGIN...
Started by Jeremy White on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
See the Standard Unix Specification's awk description for what you can expect as a baseline for ....
You're relying on an extension to awk that's present in whichever variant (gawk, mawk, nawk, etc.) your Red Hat system happens to be using.
|
|
I need to execute a command per line of some file. For example:
file1.txt 100 4 file2.txt 19 8
So my awk script need to execute something like
command $1 $2 $3
and save the output of command $1 $2 $3 , so system() will not work and neither will getline...
Started by llazzaro on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
In fact, google # cat test.txt | nl 1 ls -F | grep test 2 cat test.txt | nl 3 cat test.awk # cat test.awk #!/usr/bin/awk) print "# " cmd[i] ORS output....
That's what awk's getline does, like backticks or $(cmd) in shell/perl.
|