|
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 the following code that uses 'paste' and AWK script inside Perl.
use strict; use Data::Dumper; use Carp; use File::Basename; my @files = glob("result/*-*.txt"); my $tocheck = $ARGV[0] || "M"; foreach my $file ( @files ) { my $base = basename($file...
Started by neversaint on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
I completely agree that calling awk from Perl is just of dead/unused code....
Split /\s+/; if ($cols[3] eq "M") { # Perl uses 0-based arrays, unlike awk $col1 += $cols[1]; $col2 understand "<(process substitution)" syntax.
|
|
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
|
I know the question is very subjective. But I cannot form the question in a much more better manner. I would appreciate some guidance.
I often as a developer feel how easier it would have been for me if I could have some tools for doing some reasonably...
Started by ajay on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
As suggested by ikkebr, python is probably as good as (or better than) perl....
I would use Perl over a bash/sed/awk/sed, I usually end up using perl instead.
With it - if I was to start again, I'd learn python instead I think .
|
|
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.
|
|
Hello,
just want to know what are the main differences among them? and the power of each language (where it's better to use it).
Edit: it's not "vs." like topic, just information.
Started by Khaled Al Hourani on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
There are many differences , awk , perl....
Perl has its roots in text processing and has a number of awk-like constructs (there is even an awk-to-perl script floating around on the net).
Purpose programming languages.
|
|
Hello,
I want to replace awk with a perl one liner in unix.
i use in awk REGEX and FS ( field separator) because
awk syntaxes in different unix os versions have not the same behaviour.
Awk, Nawk and GNU Awk Cheat Sheet - good coders code, great reuse
...
Started by bora99 on
, 5 posts
by 4 people.
Answer Snippets (Read the full thread at unix):
Next, there are different ....
awk
esac
i thought " perl " was a goodOk, but be aware: perl is NOT POSIX so it is not guaranteed to be on a given unix box.
awk
Linux ) ....
Like :
case "$(uname)" in
HP-UX ) ....
RedHat ).
|
|
All of my codes fail. They should print "he", "hello" and "5 \n 3", respectively:
awk -v e='he' {print $e} // not working, why? awk NF { print hello } awk { print ARGV[5,3] }
Are there some simple examples about AWK?
Started by Masi on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
For the first, you don't use $ for variables inside awk, try this instead:
fury> echo | awk -v e empty lines:
fury> echo | awk 'NF {print "hello"}' fury> echo "7 8" | awk 'NF {print "hello use:
fury> 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.
|