Sponsored Content
Top Forums UNIX for Dummies Questions & Answers What is this? var2=${var1#??????????} Post 302298818 by vgersh99 on Wednesday 18th of March 2009 05:12:30 PM
Old 03-18-2009
'man ksh' yields:
Code:
     ${parameter%word}
           Remove Smallest  Suffix  Pattern.  The  word  will  be
           expanded to produce a pattern. The parameter expansion
           then will result in parameter, with the smallest  por-
           tion of the suffix matched by the pattern deleted.

     ${parameter%%word}
           Remove  Largest  Suffix  Pattern.  The  word  will  be
           expanded to produce a pattern. The parameter expansion
           then will result in parameter, with the  largest  por-
           tion of the suffix matched by the pattern deleted.

     ${parameter#word}
           Remove Smallest  Prefix  Pattern.  The  word  will  be
           expanded to produce a pattern. The parameter expansion
           then will result in parameter, with the smallest  por-
           tion of the prefix matched by the pattern deleted.

     ${parameter##word}
           Remove  Largest  Prefix  Pattern.  The  word  will  be
           expanded to produce a pattern. The parameter expansion
           then will result in parameter, with the  largest  por-
           tion of the prefix matched by the pattern deleted.

and a couple of examples:
Code:
     ${parameter%word}

     x=file.c
     echo ${x%.c}.o
     file.o

     ${parameter%%word}

     x=posix/src/std
     echo ${x%%/*}
     posix

     ${parameter#word}

     x=$HOME/src/cmd
     echo ${x#$HOME}
     /src/cmd

     ${parameter##word}

     x=/one/two/three
     echo ${x##*/}
     three

 

5 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

*fixed if (( var1 && var2 )) ??

*EDIT -- **FIXEd I must've done something wrong, because it works now.. I punched in "if" in the forum search but nothing came up, so I'm posting it here. Quick question: Can someone correct my syntax. #!/bin/ksh if (( var >= 1 && var <= 5 )); then .................................. (1 Reply)
Discussion started by: yongho
1 Replies

2. Shell Programming and Scripting

Echo var1,var2,var3,var4,var5,var6 in loop help

Hello, I have created numerous variables called $mask1 $mask2... $maskN. I wish to echo these variables, below is the code for the two functions, the first creates the variables and the second echos them. It is the second function which does not work. The line (i believe to be wrong) is in... (1 Reply)
Discussion started by: rorey_breaker
1 Replies

3. Shell Programming and Scripting

(probably stupidly simple) if [ $var1 = $var2 ] problem...

OK, while I'm not new to the Mac or some of the the inner workings of Mac OS X I am quite new to scripting. And while I have "Learning the Bash Shell" by those lovely people at O'Reilly (Cameron Newham et. al.) I'm missing something, I just know I am. Here's the problem: At the beginning of... (2 Replies)
Discussion started by: woodgie
2 Replies

4. Shell Programming and Scripting

concatenate varaibles var1, var2 together to var1 again

HI i like to concatenate the two variables var1=$line (ie 22885068900000652 B86860003OLFXXX592123320081227) var2=$amount (ie 123456) i want to club together both the above varaible var1 & var2 and assign back to var1 right now i am doing like this but it is not working. var1=`echo... (1 Reply)
Discussion started by: kshuser
1 Replies

5. Shell Programming and Scripting

Convert .../($var1|$var2)/... regex to string

Hello, In one part of my shell program I need to translate many of lines in the following pattern : /(folder1|...|folderN)/(sub1|...|subN)/.../(file1|...|fileN) into strings : /folder1/sub1/.../file1 /folder1/sub1/.../... /folder1/sub1/.../fileN ... /folderN/subN/.../fileN the... (2 Replies)
Discussion started by: Ghadamyari
2 Replies
randomword(3)						     Library Functions Manual						     randomword(3)

NAME
randomword, randomchars, randomletters - Generate random passwords (Enhanced Security) LIBRARY
Security Library - libsecurity.so SYNOPSIS
int randomchars( char *string, unsigned short int minlen, unsigned short int maxlen, boolean restrict, long seed); int randomletters( char *string, unsigned short int minlen, unsigned short int maxlen, boolean restrict, long seed); int randomword( char *word, char *hyphenated_word, unsigned short int minlen, unsigned short int maxlen, boolean restrict, long seed); PARAMETERS
Points at a user-supplied space to contain a null-terminated password. Specifies the minimum length that a generated word can have. Spec- ifies the maximum length that a generated word can have. Specifies whether restrictions are to be imposed on the generated word. This is a boolean integer, where a non-zero integer indications restrictions and a 0 (zero) indicates no restrictions. Specifies an initial seed for the random number generator. Points at a user-supplied space to contain a null-terminated random pronounceable password. Contains the hyphenated version of the generated word. DESCRIPTION
These functions generate random passwords for use in password selection. All of them are generated by the system, based on seeds and set in the function. Such seeds can be created with the drand48(), rand(), or random() functions. The randomchars() function places a null-terminated password composed of random printable ASCII characters into the string parameter and returns the length of the generated string. The minlen parameter can equal maxlen, but cannot be greater than maxlen, and cannot be nega- tive. The user space preallocated is at least maxlen for string. The smaller minlen and maxlen are, the smaller the selection space of random words. The restrict parameter is 0 (zero) when no restrictions are placed on the generated word. It is nonzero when the words generated pass the tests of the acceptable_password() function. The seed parameter is used by the function only on the first time it is called; the parameter is ignored on subsequent calls. The randomletters() function places a null-terminated password composed of random lower-case letters into the string parameter and returns the length of the generated word. The minlen, maxlen, restrict, and seed parameters are the same as for the randomchars() function. The randomword() function places a null-terminated random pronounceable password into the word parameter and returns the length of the gen- erated word. The minlen, maxlen, restrict, and seed parameters are the same as for the randomchars() and randomletters() functions. The user space preallocated is at least 2*max - 1 for hyphenated_word. NOTES
The password generator relies on a random number generator that produces uniformly distributed integers. Because the password generator invokes the random number generator many times even for one word, the random number generator has to produce a uniform distribution. The period (distinct numbers produced given a particular seed) and number space (range of possible numbers) must both be large. The drand48() functions are used for this purpose. Programs using these functions must be compiled with -lsecurity. FILES
System password file. System group file. RELATED INFORMATION
Functions: acceptable_password(3), drand48(3), rand(3), random(3). Commands: login(1), passwd(1). delim off randomword(3)
All times are GMT -4. The time now is 04:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy