简体   繁体   中英

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.

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, eg ls $importantdir/FILE1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM