Sponsored Content
Top Forums UNIX for Dummies Questions & Answers BASH: Change alias to script to add a task Post 302488824 by Corona688 on Tuesday 18th of January 2011 01:37:11 PM
Old 01-18-2011
If you want to use parameters, a function would be better than an alias. Not all shells have them but bash definitely does. You can use them like little callable scripts you put in your .bashrc

Code:
function homeperm
{
        local LOCALFILE="$1"
        local URL="$2"

        do_stuff_with_parameters
}

...and you'd just run it as homeperm parameter1 parameter2

And no, you never need to use 'cut' to do something as simple as that, the read command can do a lot for you:

Code:
$ read A B <<< "c d"
$ echo $A
c
$ echo $B
d
$

You can also split on something other than whitespace:
Code:
$ IFS="|" read A B <<< "c d|e"
$ echo $A
c d
$ echo $B
e
$

It's much more efficient than calling cut since read's a builtin and always a builtin.
This User Gave Thanks to Corona688 For This Post:
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Query regarding alias and setting bash as a default script

Hi All, I am setting bash as my working shell in my .profile file. So I have written a line : bash as the list line in my .profile I want to use alias as follows: alias me='who am i' When i log in, as expeced I enter the bash shell but alias doesn't work. Is it because the alias is defined... (1 Reply)
Discussion started by: VENC22
1 Replies

2. UNIX for Dummies Questions & Answers

Alias, function or script (bash) to "revert" cd command?

In all of my brief and superficial experience with Unix or Linux, the one curious and consistent thing has been that 'cd ./' (back up one directory level) has done absolutely nothing in any of them. Now I understand that, at least for bash, 'cd ./' appears to have been substituted by 'cd ..' Am... (1 Reply)
Discussion started by: SilversleevesX
1 Replies

3. Shell Programming and Scripting

Idea for an "informative" bash alias or script

I had the idea come into my head that it would be good to have a single command that gave file type, file size, last modification date, and owner/group information, like what one would see in a GUI "Properties" dialog, but all in a terminal window. In my opinion, these statistics about a file... (5 Replies)
Discussion started by: SilversleevesX
5 Replies

4. Shell Programming and Scripting

Unable to change environment variables in bash script

Hello! For the moment some settings in my .bashrc contain the password of my company's firewall, which is not a good idea. I would like to use the string "PASSWORD" set in .bashrc and a script that changes all appearances of "PASSWORD" in the environment variables by the actual password (which... (4 Replies)
Discussion started by: markolopa
4 Replies

5. Shell Programming and Scripting

How to run Cygwin bash from windows scheduled task?

Hmmm.... I love these forums because I always get great prompt responses and I want to ask a question about running bash on windows. Is that allowed? Now I know I can install cygwin cron and run bash that way. Can I run bash from windows schedule task? How? thanks siegfried (1 Reply)
Discussion started by: siegfried
1 Replies

6. Shell Programming and Scripting

How to do one line bash schedule task?

This seems to work: https://www.unix.com/shell-programming-scripting/179705-how-run-cygwin-bash-windows-scheduled-task.html However, I was hoping to avoid writing a 2 line bat files to invoke my cygwin scripts as a scheduled task (since I'm making lots scheduled tasks). I was hoping this would... (1 Reply)
Discussion started by: siegfried
1 Replies

7. Shell Programming and Scripting

Windows Task with Bash script

Hello I have a problem with use bash script in windows task. If I use script by cygwin it's working well. If I use it by Windows task I'm get error Error : ERROR 2 (HY000) at line 2: File '.\xxx.csv' not found (Errcode: 2) Code Line : load data local infile './xxx.csv' REPLACE into... (16 Replies)
Discussion started by: karp
16 Replies

8. Shell Programming and Scripting

Is it possible to change paths inside a bash script?

i have some script with some paths inside it. The idea is to some files which is on desktop copy and move to another location. Problem is that inside script is similar to this: cp test1.zip /root/help/ because I allways have another zip files, does it possible to have some input which ask me... (18 Replies)
Discussion started by: tomislav91
18 Replies

9. Shell Programming and Scripting

Change directory within a bash shell script

Hi, I have been trying to execute the below command by changing directory and then copying contents of one directory to another by doing some file name manipulations in between. However this isnt working since as soon as the statement completes it goes back to the original folder. Can someone... (5 Replies)
Discussion started by: HikingLife
5 Replies
aliasadm(1M)                                              System Administration Commands                                              aliasadm(1M)

NAME
aliasadm - manipulate the NIS+ aliases map SYNOPSIS
aliasadm -a alias expansion [options comments] optional flags aliasadm -c alias expansion [ options comments] [ optional flags] aliasadm -d alias [ optional flags] aliasadm -e alias [ optional flags] aliasadm -l alias [ optional flags] aliasadm -m alias [ optional flags] aliasadm [-I] [-D domainname] [-f filename] [-M mapname] DESCRIPTION
aliasadm makes changes to the alias map. The alias map is an NIS+ table object with four columns: alias The name of the alias as a null terminated string. expansion The value of the alias as it would appear in a sendmail /etc/aliases file. options A list of options applicable to this alias. The only option currently supported is CANON. With this option, if the user has requested an inverse alias lookup, and there is more than one alias with this expansion, this alias is given prefer- ence. comments An arbitrary string containing comments about this alias. The sendmail(1M) command reads this map in addition to the NIS aliases map and the local /etc/aliases database. OPTIONS
-a Add an alias. -c Change an alias. -d Delete an alias. -e Edit the alias map. -I Initialize the NIS+ aliases database. -l List the alias map. -m Print or match an alias. -D domainname Edit the map in domain domainname instead of the current domain. -f filename When editing or listing the database, use filename instead of invoking the editor. -M mapname Edit mapname instead of mail_aliases. FILES
/etc/aliases mail aliases for the local host in ASCII format ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWnisu | +-----------------------------+-----------------------------+ SEE ALSO
sendmail(1M), attributes(5) NOTES
NIS+ might not be supported in future releases of the SolarisTM Operating Environment. Tools to aid the migration from NIS+ to LDAP are available in the Solaris 9 operating environment. For more information, visit http://www.sun.com/directory/nisplus/transition.html. SunOS 5.10 12 Dec 2001 aliasadm(1M)
All times are GMT -4. The time now is 02:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy