ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
but that wouldnt be one line anymore, since I need a PWD=`pwd`, dont I?
Nope. PWD is an internal shell variable: it is automatically updated every time you change directory, as well as OLDPWD, which retains the path of the previous working directory (useful when you use "cd -" to return to the previous location). You can use PWD at any time and it will give you the path of your current working dir. Moreover it is common to all the shells, not only bash.
I'd recommend you to have a look at "sed" or "tr" commands online rather than copying and pasting what the others have suggested. They are really helpful commands which will come in handy.
I'd recommend you to have a look at "sed" or "tr" commands online rather than copying and pasting what the others have suggested. They are really helpful commands which will come in handy.
Your solution is indeed more efficient than mine for this problem. But a combination and tr and sed would be more powerful than the inbuilt substitution alone, for other cases. And learning these commands just take minutes. I'm just trying to make paliga know more about linux commands rather than spoon feed him.
But a combination and tr and sed would be more powerful than the inbuilt substitution alone, for other cases. And learning these commands just take minutes.
Especially sed is very powerful and if you can learn it in minutes you are a genius
Especially sed is very powerful and if you can learn it in minutes you are a genius
I agree with you. It might take a while to learn about sed from scratch. But if you've programmed before and are familiar with the concept of regular expression already then it'd just take minutes.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.