a script
The existing Linux program foo2bar takes as its only argument the name of a single foo file and converts it to an appropriately-named bar file. Provide a script that when executed will run foo2bar against all foo files in the current directory.
How would you make that script executable? |
Quote:
HTH |
Hi HTH,
Fair enough. The first part, I don’t know how to do it nor I was not able to find anything . The second part , maybe : chmod 755 foo2bar run . foo2bar |
Assuming this is for bash shell, all you need is a for loop.
Otherwise, you could always use:
About chmod, they don't say anything about the rest of permissions. So, I wouldn't touch them. I would just use chmod +x. |
Quote:
Code:
chmod +x foo2bar |
is this correct:
ls * | xargs foo2bar |
^ good idea but not quite. according to the problem you want to filter on just foo files and not everything in the current directory. also you need a method of naming the output bar file.
|
I wouldn't use ls for anything serious. I guess it's ok for an exercise, but it's better not to grow confident on wrong methods, this is the "why".
http://mywiki.wooledge.org/ParsingLs xargs is not a good thing in this case, for the reason that it passes a lot of parameters each time, and the "foo2bar" tool that you will be calling accepts only one. As said above, you need some kind of loop to read the file names one by one, so you can call "foo2bar" with a single file name on each iteration. |
Hi,
Welcome to LQ! Quote:
Quote:
Along with your text and instructor's help we can aid or direct you to a solution. These links are to aid you to gaining some understanding. Sure some may seem beyond a newbie skill level but you must start somewhere; Linux Documentation Project Rute Tutorial & Exposition Linux Command Guide Utimate Linux Newbie Guide LinuxSelfHelp Bash Beginners Guide Bash Reference Manual Advanced Bash-Scripting Guide Linux Home Networking The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links! |
@etouchqa
There's a separate thread for testing whatever one wants to test. http://www.linuxquestions.org/questi...-issue-745067/ Please do not hijack other threads... and welcome to LQ:) |
the script itself
Quote:
|
All times are GMT -5. The time now is 04:32 AM. |