Can I execute a shell command and put the result in command field?
Sometimes I have long directory path to type in command field of linux shell, it is very easily mistyped.
Such as : can I execute "pwd" in command line and make the "pwd" result shown in the command line area and let me modify the command line area to execute another command. |
If the issue is having to type it often to get cd there I would make an alias in your home directory:
Code:
ln -s /long/path/to/some/where/good/ Code:
cd good/ Code:
ln -s /long/path/to/some/where/good/ fun |
@micxz: your first example is missing the link name
@fran4tw: http://linux.die.net/man/1/ln |
I'm not sure what you are asking so this might not be relevant but ...
Code:
dir=$( pwd ) |
Quote:
|
Right catkin or use $PWD
http://tldp.org/LDP/abs/html/internalvariables.html |
Quote:
|
Quote:
Using the output of a program directly might be handy in other tasks than changing working directory, so in that sense I'd still vote for that approach. In addition it should guarantee that you get what you want to, even if the unthinkable happened and somehow $PWD got overwritten just before you typed the command (not probable, but possible). There are other ways of using the output, or rather "other notations," than the $(command) one. For example in Bash one can also use backticks, Code:
echo `pwd` |
Hi,
Along with other suggestion if you have the need to repeat entries then why not setup a .bashrc & .bash_profile for your user with aliases; Code:
sample .bash_profile; Code:
sample .bashrc; Do not forget about 'history'; Quote:
1 Linux Documentation Project 2 Rute Tutorial & Exposition 3 Linux Command Guide 4 Bash Beginners Guide 5 Bash Reference Manual 6 Advanced Bash-Scripting Guide 7 Linux Newbie Admin Guide 8 LinuxSelfHelp 9 Utimate Linux Newbie Guide The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links! |
Thanks to everyone. It really helps. But I am currently working as one man MIS, do'nt have enough time to test all these good suggestion shortly. All the suggestion will test and make the best use of them.
Best regards |
All times are GMT -5. The time now is 10:42 AM. |