[SOLVED] how to run 2 bash command back-to-back in bourneShell
SlackwareThis Forum is for the discussion of Slackware Linux.
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.
this is an excellent example of why backticks are obsolete. just use $( command ) notation instead of ` command `. there's clearly no way you can nest anything using syntax that is identical at both ends.
Chris, the /bin/sh shell doesn't provide the $(command) syntax. I think it can be easily accomplished using sed or any other editing tool, e.g
Code:
$ echo $A_PATH | sed -r 's:/[^/]+/(.*)/[^/]+:\1:'
deep/path/A/1
This code does not seem to work as advertized.
Anyway, assuming that (ba)sh is used, it is much faster (according to my naive tests, 191 times faster when used in bulk) to use the built-in substitution rather than to spawn children and open pipes:
Thank you all for the replies.
As I stated i am using Bourne shell and not Bash.
So it looks like i'll have to keep the not-so-elegant temp variable approach or switch to Dive's rev&cut one.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.