12-30-2008
Regular Expressions in If clause
Hi All,
I have a set of files in my directory like BED123C.txt, SED134F.txt,DEF567DF.txt. I want to execute separate scripts based on the file names.
I am using the following block of the code for this
for EachFile in `ls`
do
if [ EachFile = "B*" ]
then
sh Exe1.sh
fi
if [ EachFile = "S*" ]
then
sh Exe2.sh
fi
done
But it is not producing the desired result.
Can any one help me how to use regular expressions in if Condition in unix scripting?
Thanks in advance,
-- Raam.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
How can i create a regular expression which can detect a new line charcter followed by a special character say * and replace these both by a string of zero length?
Eg:
Input File san.txt
hello
hi ... (6 Replies)
Discussion started by: sandeep_hi
6 Replies
2. Shell Programming and Scripting
Hi,
can anyone advise me how to shorten this:
if || ; then
I tried but it dosent seem to work, whats the correct way.
Cheers (4 Replies)
Discussion started by: jack1981
4 Replies
3. UNIX for Dummies Questions & Answers
how to find for a file whose name has all characters in uppercase after 'project'?
I tried this:
find . -name 'project**.pdf'
./projectABC.pdf
./projectABC123.pdf
I want only ./projectABC.pdf
What is the regular expression that correponds to "all characters are capital"?
thanks (8 Replies)
Discussion started by: melanie_pfefer
8 Replies
4. UNIX for Advanced & Expert Users
Hi,
below is a piece of code written by my predecessor at work.
I'm kind of a newbie and am trying to figure out all the regular expressions in this piece of code.
It is really a tough time for me to figure out all the regular expressions.
Please shed some light on the regular expressions... (3 Replies)
Discussion started by: ramky79
3 Replies
5. Shell Programming and Scripting
Hi,
In ksh, I am trying to compare folder names having -141- in it's name.
e.g.: 4567-141-8098 should match this expression '*-141-*'
but, -141-2354 should fail when compared with '*-141-*'
simlarly, abc should fail when compared with '*-141-*'
I tried multiple things but nevertheless,... (5 Replies)
Discussion started by: jidsh
5 Replies
6. Shell Programming and Scripting
what elements does " /^/ " match?
I did the test which indicates that it matches single lowercase character like 'a','b' etc. and '1','2' etc.
But I really confused with that. Because, "/^abc/" matches strings like "abcedf" or "abcddddee".
So, what does caret ^ really mean?
Any response... (2 Replies)
Discussion started by: DavidHe
2 Replies
7. Shell Programming and Scripting
need a regex that matches when a number has a zero (0) at the end of it
so like
10
20
120
30
330
1000
and so on (6 Replies)
Discussion started by: linuxkid
6 Replies
8. Shell Programming and Scripting
I have a file that I'm trying to find all the cases of phone number extensions and deleting them. So input file looks like:
abc
x93825
def
13234
x52673
hello
output looks like:
abc
def
13234
hello
Basically delete lines that have 5 numbers following "x". I tried: x\(4) but it... (7 Replies)
Discussion started by: pxalpine
7 Replies
9. Shell Programming and Scripting
I am new to shell scripts.Can u please help me on this req.
test_user = "Arun"
if
echo "test_user is a word"
else
echo "test_user is not a word" (1 Reply)
Discussion started by: chandrababu
1 Replies
10. Shell Programming and Scripting
Hi
Ilove unix and alwyas trying to to learn unix,but i am weak in using regular expressions.can you please give me a littel brief discription that how can i understand them and how to use .your response could lead a great hand in my unix love. (1 Reply)
Discussion started by: manoj attri
1 Replies
LEARN ABOUT CENTOS
gensprep
gensprep(8) ICU 50.1.2 Manual gensprep(8)
NAME
gensprep - compile StringPrep data from files filtered by filterRFC3454.pl
SYNOPSIS
gensprep [ -h, -?, --help ] [ -v, --verbose ] [ -c, --copyright ] [ -s, --sourcedir source ] [ -d, --destdir destination ]
DESCRIPTION
gensprep reads filtered RFC 3454 files and compiles their information into a binary form. The resulting file, <name>.icu, can then be read
directly by ICU, or used by pkgdata(8) for incorporation into a larger archive or library.
The files read by gensprep are described in the FILES section.
OPTIONS
-h, -?, --help
Print help about usage and exit.
-v, --verbose
Display extra informative messages during execution.
-c, --copyright
Include a copyright notice into the binary data.
-s, --sourcedir source
Set the source directory to source. The default source directory is specified by the environment variable ICU_DATA.
-d, --destdir destination
Set the destination directory to destination. The default destination directory is specified by the environment variable ICU_DATA.
ENVIRONMENT
ICU_DATA Specifies the directory containing ICU data. Defaults to /usr/share/icu/50.1.2/. Some tools in ICU depend on the presence of the
trailing slash. It is thus important to make sure that it is present if ICU_DATA is set.
FILES
The following files are read by gensprep and are looked for in the source /misc for rfc3454_*.txt files and in source /unidata for Normal-
izationCorrections.txt.
rfc3453_A_1.txt Contains the list of unassigned codepoints in Unicode version 3.2.0....
rfc3454_B_1.txt Contains the list of code points that are commonly mapped to nothing....
rfc3454_B_2.txt Contains the list of mappings for casefolding of code points when Normalization form NFKC is specified....
rfc3454_C_X.txt Contains the list of code points that are prohibited for IDNA.
NormalizationCorrections.txt
Contains the list of code points whose normalization has changed since Unicode Version 3.2.0.
VERSION
50.1.2
COPYRIGHT
Copyright (C) 2000-2002 IBM, Inc. and others.
SEE ALSO
pkgdata(8)
ICU MANPAGE
18 March 2003 gensprep(8)