Grammin
Grammin

Reputation: 12205

How can I shorten a path in red hat linux?

So I have a bunch of files that I use for testing in a directory with a long path so say there are 10 files located at /home/grammin/testFiles/program1/important/. What I would like to do is have something in my bashrc? maybe that is like fileDir = /home/grammin/testFiles/program1/important/ and then whenever I would like to access a specific file on the command line all i have to do is type something like ls fileDir/FILE1. Thanks for the help.

Upvotes: 0

Views: 1134

Answers (4)

in your .bashrc file, add importantdir=/home/grammin/testFiles/program1/important/

Then use that variable with a dollar, e.g. ls $importantdir/FILE1

Upvotes: 0

heltonbiker
heltonbiker

Reputation: 27575

You should create a symlink to the path you want, and use the link path as a "typing shortcut" when using terminal.

For example, if you have /this/is/a/very/long/filesystem/path, you could create the link with ln -s /this/is/a/very/long/filesystem/path pth and then use ls pth/FILE1

Upvotes: 0

reader_1000
reader_1000

Reputation: 2501

you can achive this by ln command. something similar to this

ln -s /home/grammin/testFiles/program1/important/ fileDir

Running this one will be enough I think

Upvotes: 4

Dennis
Dennis

Reputation: 14477

Just set a variable: fileDir=/home/grammin/testFiles/program1/important.

Now ls $fileDir/FILE1 will have the desired effect.

Upvotes: 1

Related Questions