Sponsored Content
Top Forums Shell Programming and Scripting Passing parameter to script, and split the parameter Post 302724521 by cfajohnson on Wednesday 31st of October 2012 05:58:19 PM
Old 10-31-2012
Quote:
Originally Posted by pamu
Just change highlighted 3 as per your need(how many times you want to print)
Code:
if  [ $# -ne 1 ]
then
    echo " Usage : <$0>  <DATABASE> "
    exit 0
else
    val=$1
    echo $val | awk -F_ '{for(i=1;i<=3;i++){print $1"_"i$2}}' 
fi


There's no need for awk; use shell parameter expansion:
Code:
db=$1
for n in 1 2 3 
do
  dbn=${db%_*}_$n${db#*_}
  echo "$dbn"
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing Date as parameter with sh script

Hi I need to pass a date argument with my shell script. Can any one send me code for the same. eg For 15th Aug 2006. Iwant to pass parameter like this ./startenv.sh 08/15/2006. Everyday date argument must change. Will the below code work ? ./startenv.sh date '+%m/%d/%y' THanks... (1 Reply)
Discussion started by: pankajkrmishra
1 Replies

2. Shell Programming and Scripting

Passing a parameter while calling a script

Hello everyone I was asked to pass a parameter in the calling of a script. I´ll have two parameters London and Birmingham and I´ll need to pass this because each of these will have a specific script however with the same name. /home/script/loaddata.ksh Lond /home/script/loaddata.ksh Birm... (2 Replies)
Discussion started by: Rafael.Buria
2 Replies

3. Shell Programming and Scripting

Passing Filename as a Parameter to Another script

Hi, I have a requirement to write a script file(script1.sh) to read the file from the folder say /usr1/profiles/active and pass the file name as a parameter to another script file say (script2.sh) which would subsitute this parameter. The script2.sh will have a line like the one below ... (1 Reply)
Discussion started by: ravisg
1 Replies

4. Shell Programming and Scripting

Passing parameter from one file to shell script

Hi All, I have a 2 files. File1 i am generating using an ETL tool, which is a comman seperated delimited file which contains country code & load date. everytime, this country code will be updated from a table. It might be AB or BA & ld_date will be for which date we need to load the file. ... (7 Replies)
Discussion started by: Amit.Sagpariya
7 Replies

5. Shell Programming and Scripting

split the file based on the 2nd column passing as a parameter

I am unable to spit the file based on the 2nd column passing as a parameter with awk command. Source file: “100”,”customer information”,”10000” “200”,”customer information”,”50000” “300”,”product information”,”40000” script: the command is not allowing to pass the parameters with the awk... (7 Replies)
Discussion started by: number10
7 Replies

6. Shell Programming and Scripting

Issue in passing a parameter value from one script to another

Hi Experts, I am passing current month & day (i.e. 'Jul 21') from script aaa.ksh to zzz.ksh. The value 'Mon DD' is being used in zzz.ksh. Problem: If I pass 'Mon DD' value manually to zzz.ksh i.e. /test/zzz.ksh 'Jul 21' it works fine. However, if I pass value from aaa.ksh, it does... (2 Replies)
Discussion started by: dipeshvshah
2 Replies

7. AIX

Passing a parameter to a shell script?

I would like to run a compress script on files in certain directories. My compress_script.sh is just basically compress file* In order for me to use this I have to copy it into each directory and run it. How can I state the directory on the command line with the compress script so it... (2 Replies)
Discussion started by: NycUnxer
2 Replies

8. SCO

Parameter passing to dot shell script

OS SCO Open Server 6.0 MP4 I am trying to change the value of a enviornment variable thru a script and want to pass a parameter on the commande line, If I hard code the value inside the script the script changes the enviornment variable . mytest where my test is MYVAR=$1 export MYVAR... (6 Replies)
Discussion started by: atish0
6 Replies

9. Shell Programming and Scripting

Passing a parameter from a shell script to sqlplus

Hi All, I'm new to Linux and scripting, apologies in advance for 'stupid' questions. Please help... Im writing a script that calls a sqlplus script but the sqlplus requires inputs and i cant seem to get this to work. here is my code. #!/bin/sh TERM=vt100 export TERM... (4 Replies)
Discussion started by: Mahomed
4 Replies

10. Shell Programming and Scripting

Passing parameter filled variable to a script.

Say I have something like this to try and build a parameter string: OPT1="This is my Option"; OPT2="/folder/file"; PARMS="-u me -J \"$OPT1\" -g \"$OPT2\""; ./script.ksh -n 1 $PARMS; ./script.ksh -n 2 $PARMS; ./script.ksh -n 3 $PARMS; ./script.ksh -n 4 $PARMS; But this doesn't work. ... (2 Replies)
Discussion started by: Devyn
2 Replies
IMAP_GETMAILBOXES(3)							 1						      IMAP_GETMAILBOXES(3)

imap_getmailboxes - Read the list of mailboxes, returning detailed information on each one

SYNOPSIS
array imap_getmailboxes (resource $imap_stream, string $ref, string $pattern) DESCRIPTION
Gets information on the mailboxes. PARAMETERS
o $ imap_stream -An IMAP stream returned by imap_open(3). o $ref -$ref should normally be just the server specification as described in imap_open(3) o $pattern -Specifies where in the mailbox hierarchy to start searching.There are two special characters you can pass as part of the $pat- tern: ' *' and ' %'. ' *' means to return all mailboxes. If you pass $pattern as ' *', you will get a list of the entire mailbox hierarchy. ' %' means to return the current level only. ' %' as the $pattern parameter will return only the top level mailboxes; ' ~/mail/%' on UW_IMAPD will return every mailbox in the ~/mail directory, but none in subfolders of that directory. RETURN VALUES
Returns an array of objects containing mailbox information. Each object has the attributes $name, specifying the full name of the mailbox; $delimiter, which is the hierarchy delimiter for the part of the hierarchy this mailbox is in; and $attributes. $Attributes is a bitmask that can be tested against: o LATT_NOINFERIORS - This mailbox contains, and may not contain any "children" (there are no mailboxes below this one). Calling imap_createmailbox(3) will not work on this mailbox. o LATT_NOSELECT - This is only a container, not a mailbox - you cannot open it. o LATT_MARKED - This mailbox is marked. This means that it may contain new messages since the last time it was checked. Not provided by all IMAP servers. o LATT_UNMARKED - This mailbox is not marked, does not contain new messages. If either MARKED or UNMARKED is provided, you can assume the IMAP server supports this feature for this mailbox. EXAMPLES
Example #1 imap_getmailboxes(3) example <?php $mbox = imap_open("{imap.example.org}", "username", "password", OP_HALFOPEN) or die("can't connect: " . imap_last_error()); $list = imap_getmailboxes($mbox, "{imap.example.org}", "*"); if (is_array($list)) { foreach ($list as $key => $val) { echo "($key) "; echo imap_utf7_decode($val->name) . ","; echo "'" . $val->delimiter . "',"; echo $val->attributes . "<br /> "; } } else { echo "imap_getmailboxes failed: " . imap_last_error() . " "; } imap_close($mbox); ?> SEE ALSO
imap_getsubscribed(3). PHP Documentation Group IMAP_GETMAILBOXES(3)
All times are GMT -4. The time now is 03:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy