vgersh99's solution is good, but it might be possible to refine it a bit. Assuming a nawk/gawk (likewise untested):
What are the differences?
Direct match against all the patterns you seek at one time, i.e., no iteration over codesA on every line
No lookup in codesAs for each item found
[Old awk solution deleted --- no alternation ("|") available.]
The disadvantage here is that nawk and awk don't "capture" the thing matched, so you still do the substr call on every match (though it's in machine language and therefore fast). (I don't use gawk, but it may have a remedy for this.)
A ruby solution would work like this (and the perl solution would be similar):
Last edited by criglerj; 06-09-2005 at 02:36 PM..
Reason: Old awk solution doesn't work
I have my main script calling another script to retrive a "ls -alt" of a directory that's located in a remote location I'm sftping into.
main.sh
#!/bin/ksh
getLS.sh > output.txt
getLS.sh
#!/bin/sh
/home<..>/sftp <host@ip> <<!
cd /some/dir/Log
ls -alt
quit
!
Basically I'd like to be... (2 Replies)
I am using awk in my .ksh script but when I am trying to run in windows
its not recognising awk part of the ksh script , even when I changed it to gawk it does not work, this is how my .ksh and .bat files look like.
thanx.
#!/bin/ksh
egrep -v "Rpt 038|PM$|Parameters:|Begin |Date: |End... (1 Reply)
Hi Scripting gurus,
I need to convert following text snippet into csv. please help
Input
heading1 = data1
heading2 = data2
..
..
heading n = data n
heading 1 = data1
..
..
Output
data1,data2,....,data n (3 Replies)
Hi
Written some script to convert csv to html but could not add table headers.Below are the errors iam getting
./csv2html | more
+ awk -v border=1 -v width=10 -v bgcolor=black -v fgcolor=white
BEGIN { printf("<table border=\"%d\" bordercolor=\"%s\" width=\"%d\"... (2 Replies)
For the following perl script, can anyone help to convert it to awk statement in windows2003 server environment ?
Code:
foreach $k (sort {$a <=> $b} keys %psnum) (1 Reply)
hi...... thanks for allowing me to start a discussion
i am collecting usb usage details of all users and convert it into csv files so that i can export it into some database..
the input text file is as follows:-
USB History Dump
by nabiy (c)2008
(1) --- Kingston DataTraveler 130 USB... (2 Replies)
I have a shell script which I made with the help of this forum
#!/bin/sh
RuleNum=$1
cat bw_rules | sed 's/^.*-x //' | awk -v var=$RuleNum '$1==var {for(i=1;i<=NF;i++) {if($i=="-bwout") print $(i+3),$(i+1)}}'
Basically I have a pages after pages of bandwidth rules and the script gives... (0 Replies)
This is the final first release of the dynamic menu generator for pekwm (WM).
#!/bin/bash
function param_val {
awk "/^${1}=/{gsub(/^${1}="'/,""); print; exit}' $2
}
echo "Dynamic {"
for CF in `ls -c1 /usr/share/applications/*.desktop`
do
name=$(param_val Name $CF)
... (3 Replies)
Input file (a list of input file name with *.txt extension):
campus.com_icmp_ping_alive.txt
data_local_cd_httpd.txt
data_local_cd.txt
new_local_cd_mysql.txt
new_local_cd_nagios_content.txt
Desired output file:
data local_cd_httpd
data local_cd
new local_cd_mysql
new ... (9 Replies)
Hello,
I am working on a part of code where I need a awk or shell script to convert the given XML file to CSV or TXT file.
There are multiple xml files and of different structure, so a single script is required for converting data.
I did find a lot of solutions in the forum but... (16 Replies)
Discussion started by: Rashmitha
16 Replies
LEARN ABOUT PHP
ps_setpolydash
PS_SETPOLYDASH(3) 1 PS_SETPOLYDASH(3)ps_setpolydash - Sets appearance of a dashed lineSYNOPSIS
bool ps_setpolydash (resource $psdoc, float $arr)
DESCRIPTION
Sets the length of the black and white portions of a dashed line. ps_setpolydash(3) is used to set more complicated dash patterns.
PARAMETERS
o $psdoc
- Resource identifier of the postscript file as returned by ps_new(3).
o $arr
-$arr is a list of length elements alternately for the black and white portion.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
Drawing a dashed line
<?php
$ps = ps_new();
if (!ps_open_file($ps, "polydash.ps")) {
print "Cannot open PostScript file
";
exit;
}
ps_set_info($ps, "Creator", "polydash.php");
ps_set_info($ps, "Author", "Uwe Steinmann");
ps_set_info($ps, "Title", "Poly dash example");
ps_begin_page($ps, 596, 842);
ps_setpolydash($ps, array(10, 5, 2, 5));
ps_moveto($ps, 100, 100);
ps_lineto($ps, 200, 200);
ps_stroke($ps);
ps_end_page($ps);
ps_delete($ps);
?>
This example draws a line with a 10 and 2 points long line, and gaps of 5 points inbetween.
SEE ALSO ps_setdash(3).
PHP Documentation Group PS_SETPOLYDASH(3)