01-25-2008
Compare string to a pattern
I am new to unix and need to learn how to compare a variable $subject to a string pattern. If the variable has the word "Item" in it then it should be true. How do I do this? Currently I am using the Bourne shell but I can also use Korn or Bash.
I come from a Rexx background where strings are easy:
IF WORDPOS('Item', subject) > 0 THEN
SAY 'Found it'
END
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
one.txt
ONS.1287677000.820.log 20Oct2010
ONS.1287677000.123.log 21Oct2010
ONS.1287677000.456.log 22Oct2010
two.txt
ONS.1287677000.820.log:V AC CC EN
ONS.1287677000.123.log:V AC CC EN
ONS.1287677000.820.log:V AC CC EN
In file two.txt
i have to look for pattern which column one... (17 Replies)
Discussion started by: saluja.deepak
17 Replies
2. UNIX for Dummies Questions & Answers
Right now, my code is:
s/Secondary Ins./Secondary Ins.\
1/g
It's adding a 1 as soon as it finds Secondary Ins.
Primary Ins.: MEDICARE B DMERC Secondary Ins.
1: CONTINENTAL LIFE INS
What I really want to achieve is having a 1 added on the next line that contain "Secondary Ins." It... (4 Replies)
Discussion started by: newbeee
4 Replies
3. Shell Programming and Scripting
here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb
cat dump.sql
INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies
4. Shell Programming and Scripting
Here in the input file
23:59:13,devicename,21,server1,700
23:59:13,devicename,22,server2,200
23:59:13,devicename,23,server3,200
23:59:13,devicename,24,server4,200
23:59:13,devicename,25,server5,200
23:59:13,devicename,26,server6,200
23:59:13,devicename,27,server7,200... (6 Replies)
Discussion started by: necro98
6 Replies
5. Shell Programming and Scripting
I am trying to search a file for a patterns ERR- in a file and return a count for each of the error reported
Input file is a free flowing file without any format
example of output
ERR-00001=5
....
ERR-01010=10
.....
ERR-99999=10 (4 Replies)
Discussion started by: swayam123
4 Replies
6. Shell Programming and Scripting
Hi,
I am writing a shell script to parse some files, and gather data.
The data in the files is displayed as below.
.......xyz: abz: ......qrt: ....
.......xyz: abz: ......qrt: ...
I have tried using awk and cut, but the position of these values keep changing, so I wasn't able to get... (2 Replies)
Discussion started by: Serena
2 Replies
7. Shell Programming and Scripting
How to check if pattern is matching in variable or not.
I want to check file name in variable with the pattern.
Eg: file_name="AB1000.csv"
Check for below patterns
pattern1 = AB???
pattern2 = abc??*
if file_name == <patten1>
then
...
elif file_name == <pattern2>
---... (4 Replies)
Discussion started by: vegasluxor
4 Replies
8. Shell Programming and Scripting
The sample file:
dept1: user1,user2,user3
dept2: user4,user5,user6
dept3: user7,user8,user9
I want to match by '/^dept2.*/' but don't want to have substring 'dept2:' in output. How to compose such regex? (8 Replies)
Discussion started by: urello
8 Replies
9. UNIX for Beginners Questions & Answers
I have two files say FILE1 and FILE2.
FILE1 contains 80,000 filename in sorted order and another file FILE2 contains 6,000 filenames is also in sorted order.
I want to compare the filename for each file and copy them in to a folder when filename is matched.
File1.txt contain 80,000... (8 Replies)
Discussion started by: imranrasheedamu
8 Replies
10. UNIX for Beginners Questions & Answers
I have below code inside my awk script
if ( $0 ~ /SVC IN:/ )
{
svc_in=substr( $0,23 , 3);
if (msg_start == 1 && msg_end == 0)
{
msg_arr=$0;
}
}
else if ( $0 ~ /^SVC OUT:/ )
{
svc_out=substr( $0, 9, 3);
if (msg_start == 1 && msg_end == 0)
... (6 Replies)
Discussion started by: bhagya123
6 Replies
LEARN ABOUT DEBIAN
prima::detailedoutline
Prima::DetailedOutline(3) User Contributed Perl Documentation Prima::DetailedOutline(3)
NAME
Prima::DetailedOutline - a multi-column outline viewer with controlling header widget.
SYNOPSIS
use Prima::DetailedOutline;
my $l = $w-> insert( 'Prima::DetailedList',
columns => 2,
headers => [ 'Column 1', 'Column 2' ],
items => [
[ ['Item 1, Col 1', 'Item 1, Col 2'], [
[ ['Item 1-1, Col 1', 'Item 1-1, Col 2'] ],
[ ['Item 1-2, Col 1', 'Item 1-2, Col 2'], [
[ ['Item 1-2-1, Col 1', 'Item 1-2-1, Col 2'] ],
] ],
] ],
[ ['Item 2, Col 1', 'Item 2, Col 2'], [
[ ['Item 2-1, Col 1', 'Item 2-1, Col 2'] ],
] ],
],
);
$l-> sort(1);
DESCRIPTION
Prima::DetailedOutline combines the functionality of Prima::OutlineViewer and Prima::DetailedList.
API
This class inherits all the properties, methods, and events of Prima::OutlineViewer (primary ancestor) and Prima::DetailedList (secondary
ancestor). One new property is introduced, and one property is different enough to warrant mention.
Methods
items ARRAY
Each item is represented by an arrayref with either one or two elements. The first element is the item data, an arrayref of text
strings to display. The second element, if present, is an arrayref of child items.
When using the node functionality inherited from Prima::OutlineViewer, the item data (that is, the arrayref of text strings) is the
first element of the node.
autoRecalc BOOLEAN
If this is set to a true value, the column widths will be automatically recalculated (via "autowidths") whenever a node is expanded or
collapsed.
COPYRIGHT
Copyright 2003 Teo Sankaro
You may redistribute and/or modify this module under the same terms as Perl itself. (Although a credit would be nice.)
AUTHOR
Teo Sankaro, <teo_sankaro@hotmail.com>.
SEE ALSO
Prima, Prima::Outlines, Prima::DetailedList
perl v5.14.2 2009-02-24 Prima::DetailedOutline(3)