General :: Escape Commands In A Bashrc Alias?
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
ADVERTISEMENT
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
Feb 9, 2011
I have a script that I run using ./dom example.com.
I want to add an alias to .bashrc so that I can run it using "d example.com".
I have tried adding each of the lines below in turn but I still receive the error:
-bash: d: command not found
alias d="/bin/bash /home/user/dom"
alias d="./home/user/dom"
alias d="sh /home/user/dom"
View 3 Replies
View Related
Apr 15, 2011
attending class in the Redhat Academy Website. I was wondering how can you join the two commands of cd/usr & ls successfully in the .bashrc file?
View 10 Replies
View Related
Aug 25, 2011
I've set up an alias in .bashrc (let's call it alias1), and am trying to set up a sudo NOPASSWD rule for that particular command. So far, I've attempted:
user ALL = NOPASSWD: alias1
user ALL=(ALL) NOPASSWD: alias1
But keep getting told I have a syntax error - presumably this is because visudo doesn't recognise alias1? I've already checked that alias1 works correctly, so I assume I'm just referring to it incorrectly.
View 6 Replies
View Related
Oct 25, 2010
I have a few alias' in my .bashrc to save some typing, mostly ls type variants.
I wanted to add the following:
- give me a Long listing of ALL in Reverse Time order, (don't recurse directory)
Code:
But it doesn't work anything like the way it does on the command line
When I use the alias I get the following:
Code:
No Time, No Permissions, no group/owner ... , Why?
View 2 Replies
View Related
Apr 26, 2011
I'd like to know if there is a way to define commands in the .bashrc or .bash_profile. For instance, I want to be able to type 'work' in a terminal and set up an interactive work environment on my universities cluster. (This is done with the command 'qsub -I -X'.) I tried the following in my .bashrc file:
alias work ='qsub -I -X'
But, of course this failed, as I don't have a command work already defined. How do I go about doing this? Also, I can't assign 'qsub' an alias, since it's used with different options quite extensively.
View 5 Replies
View Related
May 30, 2011
recently I did some changes to my bashrc file the changes are as follows
export JAVA_HOME=/usr/java/jre<version>/bin/
export PATH=$PATH:/usr/java/jre<version>/bin
now I'm unable even login to the OS.
View 9 Replies
View Related
Sep 21, 2010
Okay so I have an alias that looks like this:
Code:
ALIAS sorigin {
MSG sorigin Test1
[code]...
View 1 Replies
View Related
Jun 14, 2011
When I add some path in .bashrc by commenting out old path and adding new one like this:
#EXPORT HOME_PLAY=/home/gem/old_play
EXPORT HOME_PLAY=/home/gem/play
EXPORT PATH=$PATH:HOME_PLAY
After saving above changes, I enter the command: source ~/.bashrc Now if I do echo $PATH, the path shows both the old PLAY_HOME and new PLAY_HOME. This is really bad and messes up a lot of things in my project. This problem only goes away if I logout or reboot, a rather very long process. What is happening is that the old path is added to new path element and the old path includes the old path element you want to remove.
View 10 Replies
View Related
Aug 12, 2010
sometimes there are one, sometime there are two exchanges in this log file. the 100= is the stock exchange- if there are two, they are seperated by a comma. i understand how to escape a comma in a regex, but I am having trouble with combining it.
35=8 39=1 38=1000 32=13 14=754 31=1.11 44=1.1 100=AMEX,ISE
35=8 39=1 38=1000 32=151 14=205 31=1.1 44=1.1 100=AMEX
35=U 39=2 38=1000 32=45 14=184 31=1.1 44=1.1 100=AMEX,ISE
[code]...
View 11 Replies
View Related
Jan 17, 2011
Usually when I need to replace some lines in a file, the first tool that comes to mind is sed -i:
sed -i 's|tool:.*|tool: some-tool|'
However, it's inconvenient when there are . characters in the replacement string:
sed -i 's|host:.*|host: 127.0.0.1|' Is there a better tool for this case?
View 1 Replies
View Related
Oct 20, 2009
Need little advice running this command.
watch -d 'ps aux | awk '{print $4" "$11}' | sort | uniq -c | awk '{print $2" "$1" "$3}' | sort -nr | head'
I get this error message from AWK. awk: cmd. line:1:
{print awk: cmd. line:1: ^ unexpected newline or end of string
I have tried all the usual by trying to escape the single and double quotes in the command but same result. The end result should be the a listing of memory hungry processes that are scanned every 2 seconds (watch default value).
View 2 Replies
View Related
May 3, 2011
i have a cd that shows you an empty directory unless you mount it for the joliet extensions - specifically 25 2f 40. It uses wide characters with the high half null.
View 3 Replies
View Related
Feb 27, 2011
I want something like
Code:
export ROS_PACKAGE_PATH=~/ros:$ROS_PACKAGE_PATH
to be done already for me when I open a new terminal. How do I edit the .bashrc so that this variable is always set already?
View 3 Replies
View Related
Aug 8, 2010
Is there a way to print a transcript generated using script that is coloured using ansi escape sequences while preserving the colours?
I am on OS X 10.6, but any tool that works on OS X or on Linux that can print or create a pdf file will be extremely helpful.
View 1 Replies
View Related
Jan 22, 2010
Is it possible to remove the ESC sequences in GNU Screen's output file? Things such as colours, tabs and other escape characters make their way into the log files and become difficult to decipher.
I've tried Dr. Google & Co. as well as reading the manual, but haven't been able to find anything suitable.Perhaps I've overlooked something?
View 3 Replies
View Related
Feb 25, 2011
Fedora 14
When I started I took the defaults and ended up with Evolution.
I have never managed to get it set up to send. It and godaddy are on diffferent planets.
Having used Thunderbird in the past, I downloaded it and it automagically set itself up to send and receive.
So now I use Thunderbird - BUT - when I click on a link in an html page - the mailto macro sends me to something other than THunderbird - perhaps Evolution - and nothing gets sent.
So how do I tell the system that when i click a mailto in firefox I want Thunderbird?
PS I think I found it. In firefox - edit - preferences - applications tab - mmailto - it said Evolution. I changed it so say /usr/bin/thunderbird - will now test it.
YES - Seems that asking a question triggers my brain on how to resolve it. Sorry to waste your time.
View 1 Replies
View Related
Feb 6, 2011
I wish to replace a new line with br (html) but it doesn't seem to work
Code:
message=$(echo ${FORM_message} | tr '
' '<br />' )
what it gives me seems to be ... b...? I am also having problem escaping hash sign in cut command:
Code:
list=$(echo "$line" | cut -d'#;#' -f1) ;
my intention is to split the line with "#;#"
View 5 Replies
View Related
Sep 29, 2010
I have the following as my $PROMPT_COMMAND in .bashrc:
Code:
PROMPT_COMMAND='
if [ $TERM = "screen" ]; then
MYPWD="${PWD/#$HOME/~}"
[ ${#MYPWD} -gt 20 ] && MYPWD=..${MYPWD:${#MYPWD}-18}
echo -n -e "33k$MYPWD33\"
fi
'
I am trying to append items to my PROMPT_COMMAND in another script/on command line. If I do the following:
[Code]....
I get no error. I've echoed the value of $PROMPT_COMMAND in both cases and their output is exactly the same.
View 4 Replies
View Related
Feb 25, 2010
I'd like a function in my .bashrc file that would allow me to pass text to it and echo the text to a specified file. I know it's simple as "echo 'text' >> file," but ideally, I would want to alias the function so I execute something like:
Code:
user~ $ write 'this is a test' with "write" being the function, and 'this is a test' being echoed to the file. I hope I explained that well enough.
View 3 Replies
View Related
Apr 5, 2010
A cluster with a head node and compute nodes. An application with a couple of env variables (App_HOME, PATH) set in .profile (default shell sh). If I login to the head node/compute nodes on a terminal everything works fine. The correct env variables are set and the application works. However, when my application tries to do it, say ssh <compute node1> <application>, it appears the environment variables are not available. It only looks in the minimal /bin, /usr/bin type PATH. This tells that the .profile is not being read
View 2 Replies
View Related
Oct 29, 2010
I would like to replace gvim with vim in the terminal. One of the nice things about gvim is that it is able to display text using italics.
Vim allows setting an ANSI escape code for italics (e[3m), but this does not work in gnome-terminal. Is there a terminal emulator that supports the ANSI escape code for italics?
View 1 Replies
View Related
May 2, 2011
I am trying to use sed command to repalce one string with other but somehow replacement string contains forwards slash hence getting the error statement garbled!
[Code]...
View 4 Replies
View Related
Oct 16, 2010
I need to source the my /home/me/.bashrc file every time I "su -" to root. Is there any way to automate this? I cannot edit any thing in the root's environment as it is shared by people.
View 7 Replies
View Related
Feb 21, 2011
In my .bashrc file, I am attempting to set JAVA_PATH to a local path, using the HOME environment variable or '~' symbol as shown in the following examples.Using ${HOME}
export JAVA_PATH='${HOME}/Software/java/jdk1.6.0_24'
When I attempt to use ${JAVA_HOME} in a my ${PATH} javec is not found. To debug it, I tried a simple ls command:
ls ${JAVA_HOME}
and get the following error:
ls: ${HOME}/Software/java/jdk1.6.0_24/: No such file or directory
Using '~': Trying to use '~' symbol as follows:
export JAVA_PATH='~/Software/java/jdk1.6.0_24'
the ls command results in the same error, however javac is found.I prefer the '~' symbol anyway, but would like to understand why the ls command does not work for either, and why it seems as though ${HOME} is not being expanded.
View 2 Replies
View Related
Apr 11, 2010
I accidently deleted my .bashrc file. I am a Debian user.Wat should i do??
View 7 Replies
View Related
Apr 16, 2011
I am trying to include my directory /usr/sbin in it's serch path for executable files using an environment variable. Would the input be: PATH="/usr/sbin"? And also upon start up, my shell should create the PRINTER environment variable which should resolve to the word sales...would that input be: PRINTER="sales"? If someone could help me with these two questions,
View 3 Replies
View Related
Nov 12, 2010
How to create /.bashrc in my home directory? do i make a folder naming it /.bashrc or i make its as a file?
View 7 Replies
View Related
Feb 11, 2011
I want to assign the path of a sourced sub.bashrc file to an environment variable. E.g. if I type (or execute) from a known relative location
$ source ../../someDir/sub.bashrc
the sub.bashrc should set a variable like
export MyOwnLocation=/home/user1/unknownlocation/someDir
The problem is I can't use $0 as reference because the script is only sourced not executed. I also don't want to hardcode the path because the location might change and there will be more copies. Is there an easy way to create this information from within the the sourced bashrc file? I use Gnu bash 2.05b on Suse Linux 9.
View 6 Replies
View Related