Results 1 to 5 of 5
Lots of commands in Linux require you to type in paths and filenames. Occasionally, they can get long and convoluted. Surely, there's a way around that?
How can I store ...
- 12-28-2006 #1Just Joined!
- Join Date
- Dec 2006
- Posts
- 13
Saving some time when working with paths
Lots of commands in Linux require you to type in paths and filenames. Occasionally, they can get long and convoluted. Surely, there's a way around that?
How can I store the current working directory into some sort of variable? And then be able to use that variable in a command later on? And then delete the variable when I'm done with it?
Also, how can I do the same with one of the files listed when I enter the ls command? For example, one of the files I was working with lately was called j2sdk-1.4.2-03-linux-i586.bin, which is a monster of a name to type in manually. Is there a way to save some time and effort here?
All tips welcome, and thanks in advance!
- 12-28-2006 #2Linux User
- Join Date
- Feb 2006
- Posts
- 484
for get the current working directory with full path use the pwd command
and use the command substitute operators `` (its not "" or '')
example:
/dir1/dir2/dir3
cd /dir1/dir2/dir3
pwd
/dir1/dir2/dir3
to run application in the dir3 which not contained in the $PATH
`pwd`/application
or us the "./" syntax
./application
2.
for long names use the bash complement function use TAB key
example
you want run j2sdk-1.4.2-03-linux-i586.bin in /dir1/dir2/dir3 with full path
a,
cd /dir1/dir2/dir3
`pwd`/j2sdk-{PRESS TAB KEY} it will became /dir1/dir2/dir3/j2sdk-1.4.2-03-linux-i586.bin , and hit enter
or
./j2sdk-{PRESS TAB KEY}
- 12-28-2006 #3
You can add a variable to your environment like this:
Then, you can use "C" as a substitute for the long path name like this:Code:daan@schmauck:~$ C=/home/daan/code
Note the need for a $.Code:daan@schmauck:~$ echo $C /home/daan/code daan@schmauck:~$ cd C bash: cd: C: No such file or directory daan@schmauck:~$ cd $C daan@schmauck:~/code$
There's no need to delete when you're done, your variable will have a limited scope and is gone as soon as you close the terminal window.
- 12-28-2006 #4Type j2sdk and hit tab, the shell will auto complete the file name, it's also a great way to avoid typosAlso, how can I do the same with one of the files listed when I enter the ls command? For example, one of the files I was working with lately was called j2sdk-1.4.2-03-linux-i586.bin, which is a monster of a name to type in manually. Is there a way to save some time and effort here?Put your hand in an oven for a minute and it will be like an hour, sit beside a beautiful woman for an hour and it will be like a minute, that is relativity. --Albert Einstein
Linux User #425940
Don't PM me with questions, instead post in the forums
- 12-28-2006 #5Just Joined!
- Join Date
- Dec 2006
- Posts
- 13
Thanks for the tips!


Reply With Quote
