Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
I'm totally new to scripting (I only created one before, and it was six lines long ^^), so my question is plainly : can you tell me if the script I want to create is something possible ?
Here's what I want to do : it's to create a script that, when ran from inside a folder, will start an existing command-line program, add the current folder's name to the program's parameters (i.e. -s "folder's name"), and add *.* to the parameters.
The program works fine when I manually add the folder's name and *.* to its parameters, but that's a hassle, I'd love a way to automatize that.
I know that may look foolish for a question, but I honestly don't know if that's something possible.
Can you tell me if that can be done ? (erm, and how ? ^_^)
Awesome ^_^
Thanks Cs-cam ^_^
I'll remember that !
But erm, I noticed on the trying a little problem : that only works if there aren't spaces in the folder's name or in the path to the folder :/
Is there maybe a solution, or... not, in your opinion ?
The quotes would be a neater solution and would work just as well. Changing variables like IFS can lead to trouble if say you decided to expand the script later you might get some odd behaviour.
Thanks Binary_y2k2, with quotes, the spaces are taken into account
Things are getting surprising : I tested, and observed one unexpected problem : the thing that is taken into account isn't only the folder name... it's the full path including the folder name !
Let's say my folder is in "/home/sabin/folders/folder I want to process", then the name that will be processed will be ""/home/sabin/folders/folder I want to process", instead of just "folder I want to process".
Sigh... Would you know the trick ?
I'd need to seriously work on scripting
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.