10 More Discussions You Might Find Interesting
1. UNIX for Beginners Questions & Answers
Hello. I'm trying to convert an awk script I wrote to perl (which I just started self-teaching). I tried the a2p command but I couldn't make sense of most of it.
Here was the awk code:
BEGIN{
FS = ","
print "NAME\tLOW\tHIGH\tAVERAGE"
a=0
}
{
if(a==0){
a+=1 (1 Reply)
Discussion started by: Eric7giants
1 Replies
2. Shell Programming and Scripting
Hello,
I searched online; it seems that perl use $NR as NR in awk; however it does not work for me. For example, how to re-write the following awk using perl:
awk '{ print NR}' inputfile---------- Post updated at 01:55 PM ---------- Previous update was at 12:49 PM ----------
I found... (2 Replies)
Discussion started by: littlewenwen
2 Replies
3. Shell Programming and Scripting
Hello folks.
After awk, i have decided to start to learn perl, and i need some help.
I have following output :
1 a
1 b
2 k
2 f
3 s
3 p
Now with awk i get desired output by issuing :
awk ' { a = a FS $2 } END { for ( i in a) print i,a }' input
1 a b
2 k f
3 s p
Can... (1 Reply)
Discussion started by: Peasant
1 Replies
4. Shell Programming and Scripting
Hi Everyone,
cat 1.txt
a <abc
b vfff
c 000>
d 4444
the output is:
<abcvfff000>
by using perl or awk, can get the value betwee "<abc" and ">", assume 1.txt has lots of those tags, so the output can filter out all those values.
Please advice.
Thanks (4 Replies)
Discussion started by: jimmy_y
4 Replies
5. Shell Programming and Scripting
awk -F "|" '{print $2$3$4 upto $30}' file1 > file2
Same logic, i want to write it in perl
I tried
#!/bin/usr/perl
my $line;
open FH, "<file1" or die " Can't open file $!";
open FH1, ">file2" or die "Can't open file ";
while (<FH1>){
$line = (split /\|/,$_);
print FH2 $line;... (3 Replies)
Discussion started by: pritish.sas
3 Replies
6. Shell Programming and Scripting
I have a script to get server information i wrote in perl because i would like to learn it (and I use it for work). It works great, however i would like to know if there is a good way to reduce the following line.
Sean (6 Replies)
Discussion started by: insania
6 Replies
7. Shell Programming and Scripting
hi all
I am new to awk/perl I would appreciate it if you could help!
how do I read a sub folder and their files.
e.g. simulation/10ms/router1.dat, router2.dat,..., router16.dat
simulation/100ms/router1.dat, router2.dat,..., router16.dat
simulation/300ms/router1.dat,... (14 Replies)
Discussion started by: mmoses
14 Replies
8. Shell Programming and Scripting
Hi All,
My Input file looks like below:
Input:
100,200,300
$fw=`head -1 test.csv | awk -F, '{print \$1}'`;
$fw="'$fw"
$fw="$fw'"
print $fw
Output:'100'
I want the first field to be printed in single quotes ('') like above.
I could get the ouptput but the problem is single... (6 Replies)
Discussion started by: kmkbuddy_1983
6 Replies
9. Shell Programming and Scripting
Dear Collegue
Do anybody help me to convert this AWK script to Perl script
{
for (i = 2; i <= length ($0); i++) {
x = substr($0, i , 1)
if (c > 0) {
b = b x
if (x == "(") c++
... (2 Replies)
Discussion started by: jaganadh
2 Replies
10. Shell Programming and Scripting
Hello Guys,
I am refering to this great forum once again for help.
After various attempts at this, I am still failing to obtain the desire effect.
I have to write a perl script which:
1- reads two values from the user (e.g name & passwd)
2- check each value against a file containing the... (7 Replies)
Discussion started by: bionicfysh
7 Replies