Sponsored Content
Full Discussion: %.*s function in shells
Top Forums Shell Programming and Scripting %.*s function in shells Post 26514 by Perderabo on Tuesday 20th of August 2002 08:31:41 AM
Old 08-20-2002
Interesting problem. I have tested the script below and it seems to work.
Code:
#! /usr/bin/ksh

ostring=$1   # original string
char=$2      # character to append
nchar=$3     # how many chars are needed

typeset -Z${nchar} suffix=0
suffix=$(echo $suffix | sed s/0/${char}/g)
echo ${ostring}${suffix}

exit 0

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Shells

I have came across the definitions of these shells korn bourne c etc .. but honestly till now i din't get the exact difference between these threes , the advantages ..... can anyone pinpoint me where it actually lies ..... don;t include me answers like aliasing in c is posible and not in bourne ..... (3 Replies)
Discussion started by: dino_leix
3 Replies

2. Linux

Version of Shells?

Can anyone tell me the version of shells for bash mc pdksh tcsh zsh For Red Hat Enterprise 4? Thank you very much! (2 Replies)
Discussion started by: Xplore
2 Replies

3. Shell Programming and Scripting

control sub-shells

Hi all, New to shell scripting, I would like to know if it is possible to pass commands to a shell, which has been launched by a parent shell. Example: #!/bin/ksh # # Launch and command shells # . mySecondShell.ksh #this launches a sub-shell #now is something like this possible?... (7 Replies)
Discussion started by: MarkZWEERS
7 Replies

4. UNIX for Advanced & Expert Users

How to set a label/number for a function in a shells script

Can any one let me know like how cn i set an label or number for each function whihc are there in an shells script: for example cd /opt/qcom/test/ function1() function2() function3() ------- i ahe a script like this .now i want to count each of this function like 1, 2, 3,............... (3 Replies)
Discussion started by: lalitka
3 Replies

5. UNIX for Advanced & Expert Users

why we have different shells?

Can you pls. tell me, why we have different shells in UNIX OS ( Eg. SunOs) and also I would like to know what is the specific difference b/w SVR and BSD ? Thanks. (2 Replies)
Discussion started by: shahnazurs
2 Replies

6. Shell Programming and Scripting

Switching between shells

I don't know why, but it just isn't working how I want it to work. You might want to run it to see what I mean. Or you might be a genius (or just really good at unix) and know just by looking at it what the problem is. Have fun trying to figure this one out.:wall: (11 Replies)
Discussion started by: nowruzr
11 Replies

7. Shell Programming and Scripting

Calling a function which uses expect from a shells script

Hi all, This is the first time i am using expect. I am trying to call a function with in the shell script. The function will shh to a new server and will pass the password using expect and send. I need help in calling the fuction i am getting follaowing errors... here the script ... (8 Replies)
Discussion started by: firestar
8 Replies

8. UNIX for Dummies Questions & Answers

shells and scripts

So in UNIX, I understand that there are several different shells you can be in: C, Bourne, Bourne Again, Korn, etc. I also know that you can write scripts for the shells, by assigning it by #!/bin/csh, or sh, etc. If I am working in the csh, do I have to write the script for the csh? Or can it... (1 Reply)
Discussion started by: bjstaff
1 Replies

9. UNIX for Dummies Questions & Answers

Shells

Lets say my default shell is bash and then i load up csh and then ksh. How would i exit csh without exiting ksh? so basically i gone from bash > csh > ksh and i wish to close csh (2 Replies)
Discussion started by: Bill Thompson
2 Replies

10. UNIX for Dummies Questions & Answers

Please what are shells?

I mean like this: http://shells.red-pill.eu/ Can anyone explain how this works? I hope my post is not spam. I think its related to linux. Thank you (1 Reply)
Discussion started by: postcd
1 Replies
BASENAME(1)						    BSD General Commands Manual 					       BASENAME(1)

NAME
basename, dirname -- return filename or directory portion of pathname SYNOPSIS
basename string [suffix] basename [-a] [-s suffix] string [...] dirname string DESCRIPTION
The basename utility deletes any prefix ending with the last slash '/' character present in string (after first stripping trailing slashes), and a suffix, if given. The suffix is not stripped if it is identical to the remaining characters in string. The resulting filename is written to the standard output. A non-existent suffix is ignored. If -a is specified, then every argument is treated as a string as if basename were invoked with just one argument. If -s is specified, then the suffix is taken as its argument, and all other arguments are treated as a string. The dirname utility deletes the filename portion, beginning with the last slash '/' character to the end of string (after first stripping trailing slashes), and writes the result to the standard output. EXAMPLES
The following line sets the shell variable FOO to /usr/bin. FOO=`dirname /usr/bin/trail` DIAGNOSTICS
The basename and dirname utilities exit 0 on success, and >0 if an error occurs. SEE ALSO
csh(1), sh(1) STANDARDS
The basename and dirname utilities are expected to be IEEE Std 1003.2 (``POSIX.2'') compatible. BSD
April 18, 1994 BSD
All times are GMT -4. The time now is 05:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy