General :: Set Alias In Bash Scripts
Sep 6, 2010
I tried this to set an alias: alias lsf='ls -f' and it works fine... But when I put it in a bash script it doesnt work. SCRIPT:
cd ~
alias lsf='ls -F'
lsf
I get the following output: line 3: lsf: command not found
View 2 Replies
ADVERTISEMENT
Jun 8, 2011
I have trouble with using an alias inside aash function. I would like to ssh into multiple machines by executing:ssh machine To achieve this, I put something like the following into my ~/.bashrc:
alias machine='user@machine'
ssh()
{
[code]....
View 1 Replies
View Related
Jul 6, 2010
I have packer installed for AUR packages, but I want to be able to use the pacman command for both. I think I will need a function for this -- what I mean is that whenever I use pacman, it will try using packer and if that fails (invalid option) it will use pacman-color. It could also decide which program to use based on the arguments. I can't just use packer (alias pacman='sudo packer') because packer doesn't have some options like -R to remove packages. I want to always use it to install and upgrade packages however, because It can install from the default repositories as well as AUR.
Does someone know how to accomplish this, or could point me in the right direction? I'm new to bash scripting. error (e.g. pacman -V prints packer: Option '-V' is not valid.).
View 1 Replies
View Related
Jan 28, 2010
I know that using alias I can run a whole command with a shortcut. But my requirement is to use parts of a long command and in between I have to pass some user defined values.
E.g. Suppose I have to routinely copy a directory to another remote directory on a remote machine.The remote machine name is quite long as well as the directory path to which I want to copy the files into.So the command to do scp would look like this[URL]Now I want to do some sort of aliasing (say "ecp") so that I just need to pass the source_directory name and the ecp command and do my job
View 3 Replies
View Related
Jul 15, 2010
I am trying to execute executable files in bash without adding ./ I know there must be an alias to add in .bashrc, that must be something like alias PATH=$PATH:. But this seems not to be working.
View 1 Replies
View Related
Feb 14, 2011
This should be a simple thing to accomplish, but I can seem to figure it out. Essentially, I want to have a bash alias or function that will let me recursively grep the current directory. A while back I added this to my .bashrc:
Code:
alias rg="grep -r --exclude=*/.svn/* --exclude=*.swp"
This works fine, (and also ignores any svn and vim swp files), and I can call it like:
Code:
rg foo *
However, 99.999% of the time, I am only interested in searching in the current directory, so the "*" is a bit redundant. Also, I would say 5-10% of the time, I am typing faster than thinking and forget the "*", so grep just sits there trying to read from stdin. It's a pretty minor thing, but ideally I'd like to be able to just type:
Code:
rg foo
I've tried creating a function to handle this:
Code:
function rg(){
grep -r --exclude=*/.svn/* --exclude=*.swp $1 *
}
but it behaves exactly the same as the alias above. escaping the "*" with 's doesn't work, and neither does trying `pwd` (or even a hard-coded path) in its place.
View 2 Replies
View Related
Aug 2, 2010
I am going through and old .cshrc file and it contains the following alias:
alias pwd 'echo $cwd'
I used to think that this is how pwd might have been implemented. But looks like thats not the case (because then this alias is meaningless).
View 2 Replies
View Related
Feb 18, 2010
I was trying to add new alias "alias ls='ls --color=auto'" in .profile, but it never worked I displayed all the alias that are current available and did not see the one I just added and found this among them:
lsls $LS_OPTIONS
and the LS_OPTIONS is "-N --color=none -T 0"
this is in /etc/csh.cshrc file which I do not have permission to edit.
Is there way to overwrite it?
Also I do not see a .cshrc under my home directory. Can I just make one and source it? Or do I have to link it to some source file that already exists?
View 3 Replies
View Related
Jan 2, 2010
I would like to use something like a 'cdl' alias that would cd into the directory i choose and then ls the contents automatically. I find myself using ls after i cd into a directory all the time. Something like:
alias='cdl=cd $1;ls'
usage: cdl /local/dir
View 2 Replies
View Related
Apr 29, 2011
I'm testing out the aliases to have a better understanding on how to shorten commands. I am trying to list all files whose file names end with a .c extension in which starts from the current working directory and recursing through subdirectories as well. And I want to delay the path name expansion until the alias is executed. I want to use the directory /usr/share. Would the command be: alias findc='find -type d -exec /usr/share'?
View 3 Replies
View Related
Aug 5, 2010
i have to set up a alias like:alias ll='ls -l'them ll will work
View 2 Replies
View Related
Sep 25, 2010
I have an alias that I would like to use both as a regular user and as root, via sudo. Specifically, it is this:
alias rm=trash This works fine as a normal user, and it works fine when I use sudo -i to get a root shell prompt, but if I use sudo rm, the alias does not apply. So where do I need to put my alias so that it works in one-off sudo commands?
View 1 Replies
View Related
Mar 4, 2011
I'm running Utorrent server and I figure I would create an alias to launch the program and run it in the background.alias utorrent='/home/user1/software/utorrent-server-3.0/utserver &'It seems to run the program but the associated webui program is flaky and won't start correctly.If I manually go to the specified path and run the command ./utserver & , I never seem to have an issue with the webui.I was wondering if this could possibly have anything to do with using the '&' ampersand operator in an alias.
View 2 Replies
View Related
Nov 5, 2009
how to save alias permanent
View 4 Replies
View Related
Dec 3, 2010
I used the alias command to make ll be ll -lrt. I have linux 5 and using the bash shell. now I can't even use ll, only ls. when I go into the bin directory, ll is not in the list and the normal color codes for bash are not showing either...folders blue, etc
View 4 Replies
View Related
Sep 17, 2010
I need to occasionally touch a file with the current timestamp as the filename. I would do so this way:
touch `date "+%Y-%m-%d_%H-%M"`.txt
However, I'd like to define an alias for this. When I try adding to the bashrc this:
alias td="touch `date "+%Y-%m-%d_%H-%M"`.txt"
the result is that the filename is the same during the entire session, since the `date ..` gets calculated just once during login...
How can I get the command to expand only when I call the alias? Or must I use a function for this?
View 1 Replies
View Related
May 25, 2011
In my laptop, if I type below
$ which vi
alias vi='vim'
/usr/bin/vim
Now I want to change the vi alias to another bin, e.g. vim_wrapper a script created in /usr/bin/, I type this line:
alias vi="vim_wrapper"
in ~/.bashrc or /etc/bashrc, but take no effects. So How to change the default vi alias vi='vim' to vi='vim_wrapper'?
View 1 Replies
View Related
Jan 15, 2010
I need to make a alias and I am a little confussed how to do it. As some websites say it has to be in profile and other says it goes in bashrc.on the server I have these files
bash_historybash_profilebashrccshrcdtprofileloginmysql_historynewsrcI been trying to do this and think may have problem now as when I log in I get error it says bash_profile syntax error unexpected token 'fi'
View 9 Replies
View Related
Mar 12, 2010
the problem is that i want to alias my cd cmd in such a way that whensover i enter any directory, a ls cmd i automatically performed. i tried ' alias cd='cd $1;ls' , but it is not working.
View 5 Replies
View Related
Aug 13, 2010
I would like to create several aliases to eth0, but have the addresses assigned by DHCP instead of being set to static IP's. Is this even possible? All the examples I've seen assign a static IP using the command:
ifconfig eth0:0 192.168.1.11 up
View 5 Replies
View Related
Apr 5, 2011
When at the command line, I find that I have to type out this command very often: find . -iname "*php" -exec grep -H query {} ; I'd love to set up an alias, script, or shortcut to make it work easier. I would like to do something like: mysearch query ("*php") (.) It would be great if the command could accept three arguments, in reverse order:
query string, file name expression, directory If the second two arguments were omitted they would default to not being included, and the current directory. Finally, the icing on the cake would be that if additional variables were included (4th, 5th, 6th...) they would be injected as additional arguments for the find command (like I could say -type d) at the end. Attempted code I tried the example below, but I'm still having trouble setting default values. What am I doing wrong?
#!/bin/bash
c=${param1+.}
b=${param2+*}
a=${param3+test}
find $c -iname $b -exec grep -H $a {} ;
View 1 Replies
View Related
Jul 4, 2011
I'm trying to setup an alias, that when I change to another directory, any directory, it will also display all its contents like ls -al:Well, that doesn't work. I guess it's an issue with the use of wild-cards.Maybe I should define a new, so far unused, name for the alias like cdl for example.Would be great if someone could help me. I search in several examples for bash aliases but couldn't find the right solution.
View 9 Replies
View Related
Aug 9, 2011
I have a program which mounts /dev/sdb1 for which I lack the source code. This device does not exist on my RedHat 9 system and I want to create /dev/sdb1 such that it's an alias for /dev/hdb1 Can I do this? with MAKEDEV?
I need to have an alias which will allow it to mount, not create a symbolic link to an already mounted directory. i.e. 'mount /dev/sdb1 /mnt/harddrive' should actually mount /dev/hdb1
View 7 Replies
View Related
Oct 21, 2010
I successfully edited the .bashrc file to get ruby version manager (rvm) working. Now I would like to turn that setting into an alias so that if i type the word 'ruby' into the terminal it not only goes to the rvm settup but also defaults to my webdev folder which is in my user home directory and also exicutes a command that will open up gedit ready to be used as the text editor for editing the .rb files. Can this be done i would settle for some added code for the 'if then' statement: so far it looks like this:
[Code]...
I don't want to mess with the default setup on this system too much and think things could get out of hand if i am not careful. So am cautious about doing anything at this stage. I wonder if it is possibel thought to setup that whole 'if then' statement as an 'alias'. I read a few referances to alias and looked in the manual like any good newby should but am needing your help please. getting out of the MSwindows mind set and into the linux logic is not so easy but is a great experience
View 13 Replies
View Related
Mar 7, 2010
my mail server [URL] is hosted abc@[URL] is a pop id below are alias:
user1@[URL]
user2@[URL]
user3@[URL]
fetchmail is configured to download all mail for alias email id on local linux server and distribute to local users.
fetchmailrc config:
[Code]....
everything works fine except bcc copy is not getting delivered to email alias (at local linux server). It is delivered to local postmaster account :abc@[URL] (in Linux server) I have tried all envelope option in fetchmailrc file, but it did not work.
View 1 Replies
View Related
Mar 9, 2011
how to remove the network alias (ex: ifcfg-eth0:2)from RHEL5, i had deleted the ifcfg-eth0:2 file from /etc/sysconfig/network-scripts/ifcfg-eth0:3but i can still see the entry in the graphical network configuration after i issued the command system-config-network, i want to remove it from there.
View 3 Replies
View Related
Sep 8, 2010
I setup a virtual server with these configurations:
1. Mail server: POSTFIX / DOVECOT
2. Webmin / Virtualmin
I am getting email to desired folders locally but I am not getting email from outside to desired users. Emails are bounced back with message "Address not found in virtual alias table".
Recent log errors are:
Sep 8 04:25:49 server1 postfix/smtpd[28002]: cannot load Certificate Authority data
Sep 8 04:25:49 server1 postfix/smtpd[28002]: warning: TLS library problem: 28002:error:02001002:system library:fopen:No such file or directory:bss_file.c:122:fopen('/etc/pki/postfix/root.crt','r'):
[code].....
View 3 Replies
View Related
Nov 29, 2010
I create a bash script that writes another bash file. But in the generated bash file I want to write a bash command in the file and not executing it.Here's my bash file:
Code:
#!/bin/bash
cat > ~/generateGridmix2data.sh << END
[code]...
View 6 Replies
View Related
Jul 17, 2010
below are the details of my system. I have bash as my current shell, some really common commands aren't working.
Do I need to do a re-installation of bash? Or how do I install a selection of bash commands which I need? (for example a subset of [URL])
Code:
root@sdptfw:~ # uname -a
Linux sdptfw.sdpt.co.za 2.4.36 #1 Tue Jul 22 13:13:24 GMT 2008 i686 i686 i386 GNU/Linux
root@sdptfw:~ # echo $SHELL$
/bin/bash$
[Code]....
View 13 Replies
View Related
Jan 25, 2011
I have installed IDL 7.1 on my Ubuntu 9.10. And now the instruction says that I should set up an "alias" for it.I do not know what to write in my "bashrc" as an alias for IDL.
These are the place of the executable command of IDL:
/IDL/idl-7.1/bin/idl
AND
/IDL/idl-7.1/bin/idlde
Note that "idl" and "idlde" are the executable files which run the program by typing them in Terminal. I would be very grateful if anyone could help me in how to write an "alias" for my IDL.
View 7 Replies
View Related