Passing variable to Alias in Hp kshell


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Passing variable to Alias in Hp kshell
# 1  
Old 08-29-2011
Passing variable to Alias in Hp kshell

Hi all,

I have a series of directories which i open regularly. I want create an alias so that i can pass the direcotry name to alias and then this commands makes Cd to the path i need. COuld you please help on how to create an alias


ex of what i am trying but couldn't succeeded

#alias goto='cd /apps/$(echo $1 | tr '[:lower:]' '[:upper:]'
#goto Ora112
#pwd
#/apps/ORA112
# 2  
Old 08-29-2011
I don't think you can do that in an alias.

Even a fairly old ksh should have functions, though:

Code:
$ function asdf
{
echo $1
}
$ asdf qwerty
qwerty
$

This User Gave Thanks to Corona688 For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing an argument using alias to piped command

Hi. I'm trying to do a "simple" thing. grep -rls grepped_exp path | xgs where xgs is an alias to something like: xargs gvim -o -c ":g/grepped_exp" now the problem is that I want to pass the "grepped_exp" to the piped alias. I was able to do something like what I want without the... (4 Replies)
Discussion started by: hagaysp
4 Replies

2. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies

3. Shell Programming and Scripting

Passing alias to a function

The objective of this function is to validate the file full path. cat /dev/null > crontab_NOTEXISTS.txt function File_Existence # Accepts 1 parameter { file_name="$(echo $1)" echo "${file_name}" && break || echo "$file_name NOT FOUND" >> crontab_NOTEXISTS.txt } while read file_name... (7 Replies)
Discussion started by: aimy
7 Replies

4. Shell Programming and Scripting

awk alias passing a value to a variable

I am trying to turn this into an alias with no luck. I would then like to put the alias into my bashrc file. I know awk is very picky about quotes. I have tried every version of quotes, single quotes, double quotes, and backslashes that I can think of. VAR=$(xrandr | awk '$2=="connected"{s=$1}... (3 Replies)
Discussion started by: cokedude
3 Replies

5. UNIX and Linux Applications

Passing date parameter on Kshell command line

I need to execute a .ksh from command line. The ksh calls a control file and has 3 parameters. First parameter is a csv file, second the target table in oracle and third parameter is a date parameter. I am attempting the below from the ksh command line {code} => testfile.ksh filname.csv... (1 Reply)
Discussion started by: kobe24
1 Replies

6. UNIX for Dummies Questions & Answers

Passing arguments to alias with multiple commands

I have a few aliases set up on AIX servers in my .kshrc file. Some of them contain multiple commands that are piped together. A simple example would be something like this: # alias to list directory contents as root and sort by size. alias lss='sudo ls -l | sort -nbk5' When I call... (5 Replies)
Discussion started by: derndingle
5 Replies

7. Shell Programming and Scripting

How to see a variable value outside a function in kshell

Hi, I wrote a small shell script which had function C_fun() and script name is same C_fun.ksh Here is the program inside the script #!bin/ksh -x C_fun() { typeset TEXT=${1} } echo Value of TEXT $TEXT When Im running the above script with Parameter "R" as the option .... (6 Replies)
Discussion started by: somu_june
6 Replies

8. UNIX for Dummies Questions & Answers

Using * when passing argument to alias

I have some folders with this structure: /data/me/a123xxx Where "xxx" is some changing series of letters, and "123" changes so folders might look like: /data/me/a123xxx /data/me/a234ysd /data/me/a534sds etc. The numbers are what matter to me (they identify the folder), so I created an... (7 Replies)
Discussion started by: ramparts
7 Replies

9. UNIX for Dummies Questions & Answers

Alias with variable?

I'm new to UNIX. I have to run executables often, and they all have a common prefix "prefix_". Now I'm wondering if I can make an alias where I can type run xyz that will then execute "./prefix_xyz" ? Thanks in advance. (1 Reply)
Discussion started by: JustinT
1 Replies

10. UNIX for Dummies Questions & Answers

Passing arguments to an alias

I want to have an alias for the command fold -78 filename | lp How do I set my alias so that the argument passed is filename ?? alias lp='fold -78 | lp' then lp filename wont work cuase this is fold -78 | lp filename (1 Reply)
Discussion started by: pmcg
1 Replies
Login or Register to Ask a Question