12-22-2009
my ksh does not support sub=$(line:4:2);
I have to use sub=$(expr substr $line 4 2);
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
Is there any code in Perl which can differentiate between numeric and non-numeric input? (11 Replies)
Discussion started by: Raynon
11 Replies
2. Shell Programming and Scripting
Hi,
I am new stuff to learn substr() function through awk for writing the Korn shell script.
Is there a way to copy from XXXX1234.ABCDEF to XXX1234 file names without changing both data files?
I appreciate your time to response this email.
Thanks,
Steve (4 Replies)
Discussion started by: sbryant
4 Replies
3. Shell Programming and Scripting
What is the difference between test expr VS .
For example :
if test 5 -eq 6
echo "Wrong"
and
if
echo "Wrong"
bot will give the same output as Wrong.
Now, what is the difference between these two? though they are producing the same result why we need two?
Any answer will be... (2 Replies)
Discussion started by: ashok.g
2 Replies
4. Shell Programming and Scripting
hi
iam trying to extract a certain portion of the string whose value is stored below,but am getting syntax eror.The command is shown below
for file in GMG_BASEL2*.txt
do
m1= cat reporting_date.txt
year= expr substr $m1 1 2
echo $year
done
m1 has date 10/31/2009
but this vale... (6 Replies)
Discussion started by: jagadeeshn04
6 Replies
5. Shell Programming and Scripting
Hi all,
i am facing the error "expr: non-numeric argument" when i use the expr command.
Following is the expression which i want to execute
HR=$(echo `date +%H`)
MIN=$(echo `date +%M`)
TOT_MIN=`expr "$HR" \* 60+$MIN` | bc
echo $TOT_MIN
Here I am being reported with the error expr:... (6 Replies)
Discussion started by: sparks
6 Replies
6. UNIX for Dummies Questions & Answers
Can someone tell me how to change the first column in a very large 17k line file from a random 10 digit numeric value to a non numeric value. The format of lines in the file is:
1702938475,SNU022,201004
the first 10 numbers always begin with 170 (6 Replies)
Discussion started by: Bahf1s
6 Replies
7. Shell Programming and Scripting
Hi all,
I want to get each line of a data file from position 464 plus 8 characters. I tried in two different ways, and the results were different. I'd like to know why.
First method, using awk:
awk '{print substr($0,464,8)}' CONCIL_VUELTA_ALF_100112_0801.okSecond method, using scripting:... (5 Replies)
Discussion started by: AlbertGM
5 Replies
8. Shell Programming and Scripting
Hi All,
I'm writing a shell script in KSH, where I want to store the filename, total record count and actual record count of all the source files. The source files reside in 4 different sub-folders under the same root folder.
Below is code:
#!/usr/bin/ksh... (6 Replies)
Discussion started by: jagari
6 Replies
9. UNIX for Dummies Questions & Answers
awk '/^>/{id=$0;next}length>=7 { print id, "\n"$0}' Test.txt
Can I use substr to achieve the same task?
Thanks! (8 Replies)
Discussion started by: Xterra
8 Replies
10. Shell Programming and Scripting
Hi,
I tried to look up the issue i'm experiencing, but i'm confused what's wrong with my script.
After executing the script I'm getting the following error
expr: non-numeric argument
syntax error on line 1, teletype
After some research, it seems that the problem relates to bc.
I have... (1 Reply)
Discussion started by: nms
1 Replies
EXPR(1) General Commands Manual EXPR(1)
NAME
expr - evaluate arguments as an expression
SYNOPSIS
expr arg ...
DESCRIPTION
The arguments are taken as an expression. After evaluation, the result is written on the standard output. Each token of the expression is
a separate argument.
The operators and keywords are listed below. The list is in order of increasing precedence, with equal precedence operators grouped.
expr | expr
yields the first expr if it is neither null nor `0', otherwise yields the second expr.
expr & expr
yields the first expr if neither expr is null or `0', otherwise yields `0'.
expr relop expr
where relop is one of < <= = != >= >, yields `1' if the indicated comparison is true, `0' if false. The comparison is numeric if
both expr are integers, otherwise lexicographic.
expr + expr
expr - expr
addition or subtraction of the arguments.
expr * expr
expr / expr
expr % expr
multiplication, division, or remainder of the arguments.
expr : expr
The matching operator compares the string first argument with the regular expression second argument; regular expression syntax is
the same as that of ed(1). The (...) pattern symbols can be used to select a portion of the first argument. Otherwise, the
matching operator yields the number of characters matched (`0' on failure).
( expr )
parentheses for grouping.
Examples:
To add 1 to the Shell variable a:
a=`expr $a + 1`
To find the filename part (least significant part) of the pathname stored in variable a, which may or may not contain `/':
expr $a : '.*/(.*)' '|' $a
Note the quoted Shell metacharacters.
SEE ALSO
sh(1), test(1)
DIAGNOSTICS
Expr returns the following exit codes:
0 if the expression is neither null nor `0',
1 if the expression is null or `0',
2 for invalid expressions.
7th Edition April 29, 1985 EXPR(1)