开发者

How can I shorten a path in red hat linux?

开发者 https://www.devze.com 2023-04-10 09:49 出处:网络
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 somet

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 开发者_StackOverflowlike 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.


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


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

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


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


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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号