Sponsored Content
Top Forums Shell Programming and Scripting how does this substition work? Post 302201089 by ripat on Saturday 31st of May 2008 05:12:56 AM
Old 05-31-2008
That's a standard bash/ksh variable expansion:
Code:
       ${#parameter}
              The length in characters of the value of  parameter  is  substi‐
              tuted.   If  parameter  is  * or @, the value substituted is the
              number of positional parameters.  If parameter is an array  name
              subscripted  by  *  or @, the value substituted is the number of
              elements in the array.

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Will this work?

I'm trying to check if files already exist in a directory. They have the same basename (exsyctr1), but 4 different extensions. If the files exist, then I make backups of them, then copy them from another directory ($livecomp/data) to the current one ($copycomp/data). If they don't exist, just... (5 Replies)
Discussion started by: Ypnos
5 Replies

2. UNIX for Dummies Questions & Answers

Script doesn't work, but commands inside work

Howdie everyone... I have a shell script RemoveFiles.sh Inside this file, it only has two commands as below: rm -f ../../reportToday/temp/* rm -f ../../report/* My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Discussion started by: cheongww
2 Replies

3. UNIX for Dummies Questions & Answers

Perl Substition with multiple conditions

I have a text file that contains lines similar to the following: ----------------------------------------------------------- fall for setup CSHRC0 'gnd'; CSHR0 'gnd'; rise for setup rise for hold CSHRC0 'gnd'; CSHR0 'gnd'; fall for hold ... (4 Replies)
Discussion started by: EDALBNUG
4 Replies

4. Shell Programming and Scripting

Command substition with KSH

$var=`command <arg> <arg>` I thought there was another method $var=$(command <arg> <arg>) I thought I read saw the second example. It doesnt work (2 Replies)
Discussion started by: popeye
2 Replies

5. UNIX for Advanced & Expert Users

Regular expression / regex substition on Unicode text

I have a large file encoded in Unicode that I need to convert to CSV. In general, I know how to do this by regular expression substitutions using sed or Perl, but one problem I am having is that I need to put a quotation mark at the end of each line to protect the last field. The usual regex... (1 Reply)
Discussion started by: thomas.hedden
1 Replies

6. UNIX for Dummies Questions & Answers

Help with variable substition in sed

Hi, I'm a bit stuck trying to get my sed syntax quite right for what I'm trying to do. I have a list of directories in a file and am trying to remove some of them using sed. I can do it if I specify the directory I want to remove in the sed command and escape the "/"s like so: say I... (2 Replies)
Discussion started by: derndingle
2 Replies

7. IP Networking

NIC will not work, but it did work.

I have a client machine that was built and loaded with SCO UNIX 2.1.3, (yes it is old). The machine worked fine on the closed network that I tested on in my shop. I then had to change it to the network that it would be connected to. Below is the host file, router and subnet mask file that I usually... (0 Replies)
Discussion started by: NC user
0 Replies

8. Shell Programming and Scripting

My script work on Linux but not work in sunos.

My script work on Linux but not work in sun os. my script. logFiles="sentLog1.log sentLog2.log" intial_time="0 0" logLocation="/usr/local/tomcat/logs/" sleepTime=600 failMessage=":: $(tput bold)Log not update$(tput rmso) = " successMessage="OK" arr=($logFiles)... (7 Replies)
Discussion started by: ooilinlove
7 Replies

9. Shell Programming and Scripting

sed substition within XML tag

Hi all, I basically want to remove certain characters from within a certain XML tag: From: <mytagone>hello 1-2-3 world</mytagone> <mytagtwo>hello 1-2-3 world</mytagtwo> To: <mytagone>hello 1 2 3 world</mytagone> <mytagtwo>hello 1-2-3 world</mytagtwo> Is this possible using sed... (6 Replies)
Discussion started by: Jedimark
6 Replies

10. IP Networking

Discussion at work, would a router work pluging a cable in wan1 and lan1?

hi all. and sorry for the random question, but this sparkled a raging flame-war at work and i want more points of view situation a router, with linux of some sort, dhcp client requesting for ip in wan1 (as usual with wan ports) dhcp server listening in lan1, and assigning ip (as usual... (9 Replies)
Discussion started by: broli
9 Replies
shift(1)							   User Commands							  shift(1)

NAME
shift - shell built-in function to traverse either a shell's argument list or a list of field-separated words SYNOPSIS
sh shift [n] csh shift [variable] ksh *shift [n] ksh +shift [n] DESCRIPTION
sh The positional parameters from $n+1 ... are renamed $1 ... . If n is not specified, it is assumed to be 1. csh The components of argv, or variable, if supplied, are shifted to the left, discarding the first component. It is an error for the variable not to be set or to have a null value. ksh The positional parameters from $n+1 $n+1 ... are renamed $1 ..., default n is 1. The parameter n can be any arithmetic expression that evaluates to a non-negative number less than or equal to $#. On this manual page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a variable assignment. This means that tilde substitution is performed after the = sign and word splitting and file name genera- tion are not performed. ksh93 shift is a shell special built-in that shifts the positional parameters to the left by the number of places defined by n, or 1 if n is omitted. The number of positional parameters remaining is reduced by the number of places that are shifted. If n is specified, it is evaluated as an arithmetic expression to determine the number of places to shift. It is an error to shift more than the number of positional parameters or a negative number of places. The following exit values are returned by shift in ksh93: 0 Successful completion. The positional parameters were successfully shifted. >0 An error occurred. On this manual page, ksh93(1) commands that are preceded by one or two + are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. They are not valid function names. 5. Words, following a command preceded by ++ that are in the format of a variable assignment, are expanded with the same rules as a variable assignment. This means that tilde substitution is performed after the = sign and field splitting and file name genera- tion are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), ksh(1), ksh93(1), sh(1), attributes(5) SunOS 5.11 20 Nov 2007 shift(1)
All times are GMT -4. The time now is 07:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy