Sponsored Content
Top Forums Shell Programming and Scripting Help to Modify File Name in each function before calling another function. Post 302882430 by Don Cragun on Tuesday 7th of January 2014 12:27:25 AM
Old 01-07-2014
With any shell that recognizes POSIX shell syntax (such as bash and ksh), try:
Code:
#!/bin/ksh
FILENAME=$1
FILEDIR=$2
printf "Start: FILENAME=%s, FILEDIR=%s\n" "$FILENAME" "$FILEDIR"
FILENAME=${FILENAME%.*}
printf "After stripping 1 extension:\tFILENAME=%s\n" "$FILENAME"
FILENAME=${FILENAME%.*}
printf "After stripping 2 extensions:\tFILENAME=%s\n" "$FILENAME"
FILENAME=${FILENAME%.*}
printf "After stripping 3 extensions:\tFILENAME=%s\n" "$FILENAME"

When invoked as:
Code:
tester mdm_ind_usa.2031.fsacm.tar.zip.gz /home/dir

it produces the output:
Code:
Start: FILENAME=mdm_ind_usa.2031.fsacm.tar.zip.gz, FILEDIR=/home/dir
After stripping 1 extension:	FILENAME=mdm_ind_usa.2031.fsacm.tar.zip
After stripping 2 extensions:	FILENAME=mdm_ind_usa.2031.fsacm.tar
After stripping 3 extensions:	FILENAME=mdm_ind_usa.2031.fsacm

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calling other file function

Hi, I am pretty new to unix. Lets say i have a program(run_program) that will call another file function(functiona, in same directory): hence, inside that run_program. i will just call "functiona xx xx" to refer and use that function. this run ok until i run this program from another folder.... (3 Replies)
Discussion started by: maldini
3 Replies

2. UNIX for Dummies Questions & Answers

Calling on function from file??

This may sounds dumb, but can I call on a function from a file? For example, I have a function file full of functions like below (no shell designation): func { echo "blah blah blah 1" } func2 { echo "blah blah blah 2" } func3 { echo "blah blah blah 3" } Am I able to call on any one... (3 Replies)
Discussion started by: douknownam
3 Replies

3. Shell Programming and Scripting

Return a value from called function to the calling function

I have two scripts. script1.sh looks -------------------------------- #!/bin/bash display() { echo "Welcome to Unix" } display ----------------------------- Script2.sh #!/bin/bash sh script1.sh //simply calling script1.sh ------------------------------ (1 Reply)
Discussion started by: mvictorvijayan
1 Replies

4. Shell Programming and Scripting

SHELL SCRIPT Function Calling Another Function Please Help...

This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord but only one record is getting wrote in DB.... Please advise ASAP...:confused: function InsertFtg { FTGSTR="" echo "Saurabh is GREAT $#" let... (2 Replies)
Discussion started by: omkar.sonawane
2 Replies

5. Shell Programming and Scripting

Reading function calling statement from a file

Hi, I have a shell script 'sample.sh' which has some functions as below. #fun1 fun1() { date } #fun2() { echo hi } I want to run these functions as background processes and also redirect the output to a file. My function calling statements are in a different file 'sample.cfg' as... (3 Replies)
Discussion started by: rama_kodam
3 Replies

6. Shell Programming and Scripting

Calling a function in cpp file inside shell script

Hi I need to call a function written in a cpp file with arguments inside the shell script..Can anyone help me how to do this:( (1 Reply)
Discussion started by: rkrish
1 Replies

7. Shell Programming and Scripting

Calling Pl/sql function in shell script to modify csv

I need to 1.Open a csv 2.Process the csv i.e. Modify 2 column in the csv. To modify the column the value needs to be passed to a pl/sql function and the return value should be updated For eg: If column 2 E,then E will be passed in database function which will return Employee. 3. Write a... (5 Replies)
Discussion started by: Chinky23
5 Replies

8. Shell Programming and Scripting

Perl script for Calling a function and writing all its contents to a file

I have a function which does awk proceessing sub mergeDescription { system (q@awk -F'~' ' NR == FNR { A = $1 B = $2 C = $0 next } { n = split ( C, V, "~" ) if... (3 Replies)
Discussion started by: crypto87
3 Replies

9. Shell Programming and Scripting

Function is calling only once

In my prog if i enter the input for the 1st time it is executing correctly, but for the second time entire script is not executing it just exiting my code is #!/bin/sh checkpo() { echo "Checking the entered PO to create output text file "; IFS=$'\n' set -f var=0 for i in $(cat... (3 Replies)
Discussion started by: Padmanabhan
3 Replies

10. Homework & Coursework Questions

C++ Attempting to modify this function to read from a (;) semi-colon-separated file

After some thought. I am uncomfortable issuing my professors name where, there may be unintended side effects from any negative responses/feedback. Willing to re post if I can omit school / professor publicly, but can message moderator for validation? I am here for knowledge and understanding,... (1 Reply)
Discussion started by: briandanielz
1 Replies
GNUNET-RSA(1)						      General Commands Manual						     GNUNET-RSA(1)

NAME
gnunet-rsa - manipulate GNUnet RSA key files SYNOPSIS
gnunet-rsa [options]FILENAME DESCRIPTION
gnunet-rsa can be used to create an RSA private key and to print the corresponding public key. You must specify a filename containing an RSA private key in GNUnet format as an argument. If the file does not exist, gnunet-rsa will create a key. This may then take a while. If the option -p is given, the corresponding public key will be printed to the console. OPTIONS
-p, --print-public-key Print the corresponding public key to stdout. -P, --print-peer-identity Print the corresponding peer identity (hash of the public key) to stdout. This hash is used for the name of peers. -s, --print-short-identity Print the corresponding short hash (256-bit hash of the public key) to stdout. This hash is used for names in the zkey zone. -c FILENAME, --config=FILENAME Use the configuration file FILENAME. -h, --help Print short help on options. -L LOGLEVEL, --loglevel=LOGLEVEL Use LOGLEVEL for logging. Valid values are DEBUG, INFO, WARNING and ERROR. -v, --version Print GNUnet version number. BUGS
Report bugs by using Mantis <https://gnunet.org/bugs/> or by sending electronic mail to <gnunet-developers@gnu.org> GNUnet Mar 15, 2012 GNUNET-RSA(1)
All times are GMT -4. The time now is 10:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy