alias two words command line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting alias two words command line
# 1  
Old 07-13-2009
alias two words command line

Hello,
i would like to alias aptitude install for sudo aptitude install, is it possible, and how ?
i read the man alias page, but i think i have to use something with \ or { but i don't know exactly what.
# 2  
Old 07-13-2009
I don't know if it's possible to do exactly what you want but with aliases you can get close. If you setup the alias:

Code:
alias sapt='sudo aptitude'

you can then just run sapt install <blah>. You probably knew this but you didn't mention it so I did Smilie

You could even get fancier if you're doing installs all the time and do:

Code:
alias sapti='sudo aptitude install'

Then just run sapti <blah>

MG
# 3  
Old 07-14-2009
For posix-sh users (bash, ksh, ...):

If you like to make own "alias" with arguments, do lot of commands, ... and so on, function works same way.
Put function to the profile file or make own ex. setup file. After that you can use function like alias.

example file setup:
Code:
# using src:
#  src some
#  src
src()
{
     cd /xx/yy/src/$*
}

# you can overwrite
rm()
{
   echo "not today"
}
# or something like
mv()
{
    /bin/mv -i  $*
}

include setup to the current process, using command line or in add calling to the profile file.
Code:
.  $HOME/setup

and try ex. rm or mv.

If you have already alias rm and mv, then result is maybe something else, because shell handle first alias. Later builtin, function and using PATH.

Last edited by kshji; 07-14-2009 at 09:56 AM..
# 4  
Old 07-14-2009
An alias is processed by the shell and how it works depends on which shell is in use. mglenney assumes everyone uses csh ot tcsh. And kshji assumes everyone use bash or ksh.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace particular words in file based on if finds another words in that line

Hi All, I need one help to replace particular words in file based on if finds another words in that file . i.e. my self is peter@king. i am staying at north sydney. we all are peter@king. How to replace peter to sham if it finds @king in any line of that file. Please help me... (8 Replies)
Discussion started by: Rajib Podder
8 Replies

2. Shell Programming and Scripting

Search words in multiple file line by line

Hi All I have to search servers name say like 1000+ "unique names" line by line in child.txt files in another file that is a master file where all server present say "master.txt",if child.txt's server name matches with master files then it print yes else no with server name. (4 Replies)
Discussion started by: netdbaind
4 Replies

3. Shell Programming and Scripting

Command line: add text wrapper around words

I am trying to build a sinkhole for BIND. I created a master zone file for malicious domains and created a separate conf file, but I am stuck. I have a list of known bd domains that is updated nightly. The file simply contains the list of domains, one on each line: Bad.com Bad2.com... (4 Replies)
Discussion started by: uuallan
4 Replies

4. Shell Programming and Scripting

Copying x words from end of line to specific location in same line

Hello all i know it is pretty hard one but you will manage it all after noticing and calculating i find a rhythm for the file i want to edit to copy the last 12 characters in line but the problem is to add after first 25 characters in same line in other way too copy the last 12 characters... (10 Replies)
Discussion started by: princesasa
10 Replies

5. Shell Programming and Scripting

How to print the words in the same line with space or to the predefined line?

HI, cat test abc echo "def" >> test output is cat test abc def the needed output is cat test abc def and so on (5 Replies)
Discussion started by: jobycxa
5 Replies

6. Shell Programming and Scripting

How to set mutliple words variable from command line

I'm writing a script (C shell) to search for a pattern in file. For example scriptname pattern file1 file2 filenN I use for loop to loop through arguments argv, and it does the job if all arguments are supplied. However if only one argument is supplied (in that case pattern ) it should ask to... (5 Replies)
Discussion started by: patryk44
5 Replies

7. Shell Programming and Scripting

deleting blank line and row containing certain words in single sed command

Hi Is it possible to do the following in a single command /usr/xpg4/bin/sed -e '/rows selected/d' /aemu/CALLAUTO/callauto.txt > /aemu/CALLAUTO/callautonew.txt /usr/xpg4/bin/sed -e '/^$/d' /aemu/CALLAUTO/callautonew.txt > /aemu/CALLAUTO/callauto_new.txt exit (1 Reply)
Discussion started by: aemunathan
1 Replies

8. UNIX for Dummies Questions & Answers

how to extend words on a command line ?

within a unix window, how do you setup your session to extend a word, by hitting the "esc" key twice. e.g. ls -la scri (esc key, esc key) thankyou (6 Replies)
Discussion started by: venhart
6 Replies

9. UNIX for Dummies Questions & Answers

overlapping words on command line

i tried resize command , but it's not working...... (4 Replies)
Discussion started by: gaurav123
4 Replies

10. UNIX for Dummies Questions & Answers

Identify duplicate words in a line using command

Hi, Let me explain the problem clearly: Let the entries in my file be: lion,tiger,bear apple,mango,orange,apple,grape unix,windows,solaris,windows,linux red,blue,green,yellow orange,maroon,pink,violet,orange,pink Can we detect the lines in which one of the words(separated by field... (8 Replies)
Discussion started by: srinivasan_85
8 Replies
Login or Register to Ask a Question