10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
Im facing a weird behavior storing regular expression in a vaiable.
Let us consider
>file_name=CTP02_*.tar
when I echo the above variable its displaying below which is file
CTP02_*tar
but when I create a file with name CTP02_1234.tar, and when I echo $file_name its showing... (3 Replies)
Discussion started by: rdineshredy
3 Replies
2. Shell Programming and Scripting
I'm trying to use a series of regular expressions as variables but can't get it to behave properly.
You can see below what I'm trying to do.
Here with lowercase a-z and the same with uppercase, numbers 0-9 and again with a set of special characters, without having to type out every single... (3 Replies)
Discussion started by: 3therk1ll
3 Replies
3. UNIX for Advanced & Expert Users
Hello All,
I'm trying to extract the lines between two consecutive elements of an array from a file.
My array looks like:
problem_arr=(PRS111 PRS213 PRS234)
j=0
while } ]
do
k=`expr $j + 1`
sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt
---some operation goes... (11 Replies)
Discussion started by: InduInduIndu
11 Replies
4. UNIX for Dummies Questions & Answers
i have a command line like this in csh script
grep -i "$argv$"
which i wanted to select the line ending with string provided as argument but it couldn't interpret the '$' (ending with)..
any help? (3 Replies)
Discussion started by: ymc1g11
3 Replies
5. Shell Programming and Scripting
Hi All,
I have a sftp session log where I am transferring multi files by issuing "mput abc*.dat". The contents of the logfile is below -
#################################################
Connecting to 10.75.112.194...
Changing to: /home/dasd9x/testing1
sftp> mput abc*.dat
Uploading... (7 Replies)
Discussion started by: k_bijitesh
7 Replies
6. Programming
Hi all,
How am I read a file, find the match regular expression and overwrite to the same files.
open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat";
open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat";
while (<DESTINATION_FILE>)
{
# print... (1 Reply)
Discussion started by: jessy83
1 Replies
7. Shell Programming and Scripting
Hi All,
Below is a sample code:
print "Enter the Name: ";
my $Name = <>;
print "Word is $Name";
open (FH,"AIDNameList.txt");
while (<FH>)
{
my $line;
print "Word is $Name";
for $line(<FH>)... (12 Replies)
Discussion started by: jisha
12 Replies
8. Shell Programming and Scripting
Hi,
I have this script:
awk -v va=45 '$0~va{print}' flo2
That returns: "4526745 1234 " (this is the only line of the file "flo2".
However, I would like to get "va" to match the begining of the line, so that is "va" is different than 45 (eg. 67, 12 ...) I would not have any output. That... (3 Replies)
Discussion started by: jolecanard
3 Replies
9. Shell Programming and Scripting
Anyone know how I will use awk's variable in a regular expression?
This line of code of mine is working, the value PREMS should be a variable:
awk '$1 ~ /PREMS/ { if(length(appldata)+2 >= length($1)) print $0; }' appldata=$APPLDATA /tmp/file.tmp
The value of APPLDATA variable is PREMS.
... (2 Replies)
Discussion started by: Orbix
2 Replies
10. Shell Programming and Scripting
is it possible? if so, how?
i want to check a variable whether is it a number or letter in an if-else statement (6 Replies)
Discussion started by: finalight
6 Replies
EXPR(1) BSD General Commands Manual EXPR(1)
NAME
expr -- evaluate expression
SYNOPSIS
expr expression
DESCRIPTION
The expr utility evaluates expression and writes the result on standard output.
All operators are separate arguments to the expr utility. Characters special to the command interpreter must be escaped.
Operators are listed below in order of increasing precedence. Operators with equal precedence are grouped within { } symbols.
expr1 | expr2
Returns the evaluation of expr1 if it is neither an empty string nor zero; otherwise, returns the evaluation of expr2.
expr1 & expr2
Returns the evaluation of expr1 if neither expression evaluates to an empty string or zero; otherwise, returns zero.
expr1 {=, >, >=, <, <=, !=} expr2
Returns the results of integer comparison if both arguments are integers; otherwise, returns the results of string comparison using
the locale-specific collation sequence. The result of each comparison is 1 if the specified relation is true, or 0 if the relation
is false.
expr1 {+, -} expr2
Returns the results of addition or subtraction of integer-valued arguments.
expr1 {*, /, %} expr2
Returns the results of multiplication, integer division, or remainder of integer-valued arguments.
expr1 : expr2
The ``:'' operator matches expr1 against expr2, which must be a regular expression. The regular expression is anchored to the begin-
ning of the string with an implicit ``^''. expr expects "basic" regular expressions, see re_format(7) for more information on regu-
lar expressions.
If the match succeeds and the pattern contains at least one regular expression subexpression ``(...)'', the string corresponding to
``1'' is returned; otherwise the matching operator returns the number of characters matched. If the match fails and the pattern
contains a regular expression subexpression the null string is returned; otherwise 0.
Parentheses are used for grouping in the usual manner.
EXAMPLES
1. The following example adds one to the variable a.
a=`expr $a + 1`
2. The following example returns the filename portion of a pathname stored in variable a. The // characters act to eliminate ambiguity
with the division operator.
expr //$a : '.*/(.*)'
3. The following example returns the number of characters in variable a.
expr $a : '.*'
DIAGNOSTICS
The expr utility exits with one of the following values:
0 the expression is neither an empty string nor 0.
1 the expression is an empty string or 0.
2 the expression is invalid.
STANDARDS
The expr utility conforms to IEEE Std 1003.2 (``POSIX.2'').
BSD
July 3, 1993 BSD